API ReferenceAdvanced utilities and typesFunction
assembleTag()
function assembleTag(fields, userInputs, delimiter?): `0x${string}`;Assembles tag fields into a raw dynamic-bytes hex value.
Each field contributes either its hardcoded value or the corresponding entry from userInputs.
Fields are joined with delimiter and UTF-8 encoded. The unpadded result is returned as a
0x-prefixed hex string.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
fields | TagField[] | undefined | Ordered list of tag field descriptors. |
userInputs | Record<string, string> | undefined | Map from field name to user-provided value. |
delimiter | string | TAG_DELIMITER | Separator between segments. Set to '' to concatenate fields without any separator. Defaults to TAG_DELIMITER (`’ |
Returns
`0x${string}`
Throws
If any segment contains non-ASCII characters.
Throws
If any segment contains the delimiter (when delimiter is non-empty).
Throws
If the assembled tag exceeds TAG_MAX_BYTES.
Remarks
The tag is the LOC’s free-form bytes field (max TAG_MAX_BYTES)
that associates it with an off-chain purpose — an order id, a campaign — and is read back from the
subgraph as LetterOfCreditOrigin.tag. Pass the result
as tag on CreateStaticLOCParams or
CreateDynamicLOCParams. Values over 32 bytes require a
profile bound to LetterOfCredit V3; builders keep legacy formatting for V2-bound deployments during
the rollout.
Example
// A partner pins the first segment; the customer fills in the rest.const fields: TagField[] = [ { name: 'campaign', value: 'SPRING24' }, { name: 'orderId' },];
// Bytes left for user-entered segments: 512 minus fixed values and// delimiters.const remaining = TAG_MAX_BYTES - getFixedTagBytes(fields);if (remaining < 0) { throw new Error('fixed segments alone exceed 512 bytes');}
// "SPRING24|ORD-88213" -> raw dynamic bytes; pass as `tag` on V3// CreateStaticLOCParams / CreateDynamicLOCParams.const tag = assembleTag(fields, { orderId: 'ORD-88213' });