# Attribution.fromData

Extracts an [`Attribution.Attribution`](/ercs/erc8021/Attribution/types#attribution) from transaction calldata.

## Imports

:::code-group
```ts [Named]
import { Attribution } from 'ox/erc8021'
```

```ts [Entrypoint]
import * as Attribution from 'ox/erc8021/Attribution'
```
:::

## Examples

### Schema 0 (Canonical Registry)

```ts twoslash
import { Attribution } from 'ox/erc8021'

const attribution = Attribution.fromData(
  '0xdddddddd62617365617070070080218021802180218021802180218021'
)
// @log: { codes: ['baseapp'], id: 0 }
```

### Schema 1 (Custom Registry)

```ts twoslash
import { Attribution } from 'ox/erc8021'

const attribution = Attribution.fromData(
  '0xddddddddcccccccccccccccccccccccccccccccccccccccc210502626173656170702C6D6F7270686F0E0180218021802180218021802180218021'
)
// @log: {
// @log:   codes: ['baseapp', 'morpho'],
// @log:   codeRegistry: {
// @log:       address: '0xcccccccccccccccccccccccccccccccccccccccc',
// @log:       chainId: 8453,
// @log:   },
// @log:   id: 1
// @log: }
```

### Schema 2 (CBOR-Encoded)

```ts twoslash
import { Attribution } from 'ox/erc8021'

const attribution = Attribution.fromData(
  '0xdddddddda161616762617365617070000b0280218021802180218021802180218021'
)
// @log: { appCode: 'baseapp', id: 2 }
```

## Definition

```ts
function fromData(
  data: Hex.Hex,
): Attribution | undefined
```

**Source:** [src/erc8021/Attribution.ts](https://github.com/wevm/ox/blob/main/src/erc8021/Attribution.ts#L517)

## Parameters

### data

* **Type:** `Hex.Hex`

The transaction calldata containing the attribution suffix.

## Return Type

The extracted attribution, or undefined if no valid attribution is found.

[`Attribution.Attribution`](/ercs/erc8021/Attribution/types#attributionattribution)
