# AbiFunction.decodeData

ABI-decodes function arguments according to the ABI Item's input types (`inputs`).

## Imports

:::code-group
```ts [Named]
import { AbiFunction } from 'ox'
```

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

## Examples

```ts twoslash
import { AbiFunction } from 'ox'

const approve = AbiFunction.from(
  'function approve(address, uint256)'
)

const data = AbiFunction.encodeData(approve, [
  '0xd8da6bf26964af9d7eed9e03e53415d37aa96045',
  69420n
])
// '0x095ea7b3000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa960450000000000000000000000000000000000000000000000000000000000010f2c'

const input = AbiFunction.decodeData(approve, data) // [!code focus]
// @log: ['0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045', 69420n]
```

### ABI-shorthand

You can also specify an entire ABI object and a function name as parameters to [`AbiFunction.decodeData`](/api/AbiFunction/decodeData):

```ts twoslash
// @noErrors
import { Abi, AbiFunction } from 'ox'

const abi = Abi.from([...])
const data = '0x...

const input = AbiFunction.decodeData(
  abi, // [!code focus]
  'approve', // [!code focus]
  data
)
// @log: ['0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045', 69420n]
```

### ABI selector shorthand

You can also specify an entire ABI object and calldata. The ABI Function is extracted from the 4-byte selector:

```ts twoslash
// @noErrors
import { Abi, AbiFunction } from 'ox'

const abi = Abi.from([...])
const data = '0x095ea7b3...

const input = AbiFunction.decodeData(
  abi, // [!code focus]
  data // [!code focus]
)
// @log: ['0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045', 69420n]
```

## Definition

```ts
function decodeData<abi>(
  abi: abi | Abi.Abi | readonly unknown[],
  data: Hex.Hex,
  options?: decodeData.Options,
): decodeData.ReturnType
```

**Source:** [src/core/AbiFunction.ts](https://github.com/wevm/ox/blob/main/src/core/AbiFunction.ts#L1095)

## Parameters

### abi

* **Type:** `abi | Abi.Abi | readonly unknown[]`

### data

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

The data to decode.

### options

* **Type:** `decodeData.Options`
* **Optional**

Decoding options.

#### options.checksumAddress

* **Type:** `boolean`
* **Optional**

Whether decoded addresses should be checksummed.

## Return Type

`decodeData.ReturnType<decodeData.ExtractForSelector<abi>>`
