Skip to content

Attribution.toDataSuffix

Converts an Attribution.Attribution to a data suffix that can be appended to transaction calldata.

Imports

Named
import { Attribution } from 'ox/erc8021'

Examples

Schema 0 (Canonical Registry)

import { Attribution } from 'ox/erc8021'
 
const suffix = Attribution.toDataSuffix({
  codes: ['baseapp', 'morpho']
})
'0x626173656170702c6d6f7270686f0e0080218021802180218021802180218021'

Schema 1 (Custom Registry)

import { Attribution } from 'ox/erc8021'
 
const suffix = Attribution.toDataSuffix({
  codes: ['baseapp'],
  codeRegistry: {
     address: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
     chainId: 8453,
  }
})

Schema 2 (CBOR-Encoded)

import { Attribution } from 'ox/erc8021'
 
const suffix = Attribution.toDataSuffix({
  appCode: 'baseapp',
  walletCode: 'privy',
  metadata: { source: 'webapp' },
})

Definition

function toDataSuffix(
  attribution: Attribution.Attribution,
): Hex.Hex

Source: src/erc8021/Attribution.ts

Parameters

attribution

The attribution to convert.

attribution.appCode

  • Type: string
  • Optional

Application attribution code.

attribution.codeRegistry

  • Type: AttributionSchemaId1Registry

attribution.codes

  • Type: readonly string[]

Attribution codes identifying entities involved in the transaction.

attribution.id

  • Type: 2
  • Optional

Schema identifier (2 for CBOR-encoded).

attribution.metadata

  • Type: Record
  • Optional

Arbitrary metadata key-value pairs.

attribution.registries

  • Type: AttributionSchemaId2Registries
  • Optional

Custom code registries keyed by entity type.

attribution.walletCode

  • Type: string
  • Optional

Wallet attribution code.

Return Type

The data suffix as a Hex.Hex value.

Hex.Hex