# AbiItem.from

Parses an arbitrary **JSON ABI Item** or **Human Readable ABI Item** into a typed [`AbiItem.AbiItem`](/api/AbiItem/types#abiitem).

## Imports

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

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

## Examples

### JSON ABIs

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

const abiItem = AbiItem.from({
  type: 'function',
  name: 'approve',
  stateMutability: 'nonpayable',
  inputs: [
    {
      name: 'spender',
      type: 'address'
    },
    {
      name: 'amount',
      type: 'uint256'
    }
  ],
  outputs: [{ type: 'bool' }]
})

abiItem
//^?
```

### Human Readable ABIs

A Human Readable ABI can be parsed into a typed ABI object:

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

const abiItem = AbiItem.from(
  'function approve(address spender, uint256 amount) returns (bool)' // [!code hl]
)

abiItem
//^?
```

It is possible to specify `struct`s along with your definitions:

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

const abiItem = AbiItem.from([
  'struct Foo { address spender; uint256 amount; }', // [!code hl]
  'function approve(Foo foo) returns (bool)'
])

abiItem
//^?
```

## Definition

```ts
function from<abiItem>(
  abiItem: (abiItem | AbiItem | string | readonly string[]) & ((abiItem extends string ? internal.Signature<abiItem> : never) | (abiItem extends readonly string[] ? internal.Signatures<abiItem> : never) | AbiItem),
  options?: from.Options,
): from.ReturnType<abiItem>
```

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

## Parameters

### abiItem

* **Type:** `(abiItem | AbiItem | string | readonly string[]) & ((abiItem extends string ? internal.Signature<abiItem> : never) | (abiItem extends readonly string[] ? internal.Signatures<abiItem> : never) | AbiItem)`

The ABI Item to parse.

### options

* **Type:** `from.Options`
* **Optional**

#### options.prepare

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

Whether or not to prepare the extracted item (optimization for encoding performance).
When `true`, the `hash` property is computed and included in the returned value.

## Return Type

The typed ABI Item.

`from.ReturnType<abiItem>`
