# AbiItem Errors

## `AbiItem.AmbiguityError`

Throws when ambiguous types are found on overloaded ABI items.

### Examples

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

const foo = Abi.from([
  'function foo(address)',
  'function foo(bytes20)'
])
AbiFunction.fromAbi(foo, 'foo', {
  args: ['0xA0Cf798816D4b9b9866b5330EEa46a18382f251e']
})
// @error: AbiItem.AmbiguityError: Found ambiguous types in overloaded ABI Items.
// @error: `bytes20` in `foo(bytes20)`, and
// @error: `address` in `foo(address)`
// @error: These types encode differently and cannot be distinguished at runtime.
// @error: Remove one of the ambiguous items in the ABI.
```

### Solution

Remove one of the ambiguous types from the ABI.

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

const foo = Abi.from([
  'function foo(address)',
  'function foo(bytes20)' // [!code --]
])
AbiFunction.fromAbi(foo, 'foo', {
  args: ['0xA0Cf798816D4b9b9866b5330EEa46a18382f251e']
})
// @error: AbiItem.AmbiguityError: Found ambiguous types in overloaded ABI Items.
// @error: `bytes20` in `foo(bytes20)`, and
// @error: `address` in `foo(address)`
// @error: These types encode differently and cannot be distinguished at runtime.
// @error: Remove one of the ambiguous items in the ABI.
```

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

## `AbiItem.InvalidAbiItemError`

**Source:** [src/core/internal/human-readable/errors.ts](https://github.com/wevm/ox/blob/main/src/core/internal/human-readable/errors.ts#L206)

## `AbiItem.InvalidSelectorSizeError`

Throws when the selector size is invalid.

### Examples

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

const foo = Abi.from([
  'function foo(address)',
  'function bar(uint)'
])
AbiFunction.fromAbi(foo, '0xaaa')
// @error: AbiItem.InvalidSelectorSizeError: Selector size is invalid. Expected 4 bytes. Received 2 bytes ("0xaaa").
```

### Solution

Ensure the selector size is 4 bytes.

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

const foo = Abi.from([
  'function foo(address)',
  'function bar(uint)'
])
AbiFunction.fromAbi(foo, '0x7af82b1a')
```

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

## `AbiItem.NotFoundError`

Throws when an ABI item is not found in the ABI.

### Examples

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

const foo = Abi.from([
  'function foo(address)',
  'function bar(uint)'
])
AbiFunction.fromAbi(foo, 'baz')
// @error: AbiItem.NotFoundError: ABI function with name "baz" not found.
```

### Solution

Ensure the ABI item exists on the ABI.

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

const foo = Abi.from([
  'function foo(address)',
  'function bar(uint)',
  'function baz(bool)' // [!code ++]
])
AbiFunction.fromAbi(foo, 'baz')
```

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

## `AbiItem.UnknownSolidityTypeError`

**Source:** [src/core/internal/human-readable/errors.ts](https://github.com/wevm/ox/blob/main/src/core/internal/human-readable/errors.ts#L206)

## `AbiItem.UnknownTypeError`

**Source:** [src/core/internal/human-readable/errors.ts](https://github.com/wevm/ox/blob/main/src/core/internal/human-readable/errors.ts#L206)
