> **Can't find what you're looking for?** Use `search_docs` on the docs MCP server at `https://v3.viem.sh/api/mcp` to find what you need.

# AbiParameters Errors

:::info
`AbiParameters` is a re-export of ox's [`AbiParameters`](https://oxlib.sh/api/AbiParameters/errors). Refer to the ox documentation for the full reference.
:::

## `AbiParameters.ArrayLengthMismatchError`

The length of the array value does not match the length specified in the corresponding ABI parameter.

### Example

```ts twoslash
// @noErrors
import { AbiParameters } from 'viem/utils'
// ---cut---
AbiParameters.encode(AbiParameters.from('uint256[3]'), [
  [69n, 420n]
])
//                                               ↑ expected: 3  ↑ ❌ length: 2
// @error: AbiParameters.ArrayLengthMismatchError: ABI encoding array length mismatch
// @error: for type `uint256[3]`. Expected: `3`. Given: `2`.
```

### Solution

Pass an array of the correct length.

```ts twoslash
// @noErrors
import { AbiParameters } from 'viem/utils'
// ---cut---
AbiParameters.encode(AbiParameters.from(['uint256[3]']), [
  [69n, 420n, 69n]
])
//                                                         ↑ ✅ length: 3
```

## `AbiParameters.BytesSizeMismatchError`

The size of the bytes value does not match the size specified in the corresponding ABI parameter.

### Example

```ts twoslash
// @noErrors
import { AbiParameters } from 'viem/utils'
// ---cut---
AbiParameters.encode(AbiParameters.from('bytes8'), [
  ['0xdeadbeefdeadbeefdeadbeef']
])
//                                            ↑ expected: 8 bytes  ↑ ❌ size: 12 bytes
// @error: BytesSizeMismatchError: Size of bytes "0xdeadbeefdeadbeefdeadbeef"
// @error: (bytes12) does not match expected size (bytes8).
```

### Solution

Pass a bytes value of the correct size.

```ts twoslash
// @noErrors
import { AbiParameters } from 'viem/utils'
// ---cut---
AbiParameters.encode(AbiParameters.from(['bytes8']), [
  '0xdeadbeefdeadbeef'
])
//                                                       ↑ ✅ size: 8 bytes
```

## `AbiParameters.DataSizeTooSmallError`

Throws when the data size is too small for the given parameters.

### Examples

```ts twoslash
// @noErrors
import { AbiParameters } from 'viem/utils'

AbiParameters.decode([{ type: 'uint256' }], '0x010f')
//                                             ↑ ❌ 2 bytes
// @error: AbiParameters.DataSizeTooSmallError: Data size of 2 bytes is too small for given parameters.
// @error: Params: (uint256)
// @error: Data:   0x010f (2 bytes)
```

### Solution

Pass a valid data size.

```ts twoslash
// @noErrors
import { AbiParameters } from 'viem/utils'

AbiParameters.decode(
  [{ type: 'uint256' }],
  '0x00000000000000000000000000000000000000000000000000000000000010f'
)
//                                             ↑ ✅ 32 bytes
```

## `AbiParameters.InvalidAbiParametersError`

## `AbiParameters.InvalidAbiTypeParameterError`

## `AbiParameters.InvalidArrayError`

The value provided is not a valid array as specified in the corresponding ABI parameter.

### Example

```ts twoslash
// @noErrors
import { AbiParameters } from 'viem/utils'
// ---cut---
AbiParameters.encode(
  AbiParameters.from(['uint256[3]']),
  [69]
)
```

### Solution

Pass an array value.

## `AbiParameters.InvalidFunctionModifierError`

## `AbiParameters.InvalidModifierError`

## `AbiParameters.InvalidParameterError`

## `AbiParameters.InvalidParenthesisError`

## `AbiParameters.InvalidTypeError`

Throws when the ABI parameter type is invalid.

### Examples

```ts twoslash
// @noErrors
import { AbiParameters } from 'viem/utils'

AbiParameters.decode(
  [{ type: 'lol' }],
  '0x00000000000000000000000000000000000000000000000000000000000010f'
)
//                             ↑ ❌ invalid type
// @error: AbiParameters.InvalidTypeError: Type `lol` is not a valid ABI Type.
```

## `AbiParameters.LengthMismatchError`

The length of the values to encode does not match the length of the ABI parameters.

### Example

```ts twoslash
// @noErrors
import { AbiParameters } from 'viem/utils'
// ---cut---
AbiParameters.encode(
  AbiParameters.from(['string', 'uint256']),
  ['hello']
)
// @error: LengthMismatchError: ABI encoding params/values length mismatch.
// @error: Expected length (params): 2
// @error: Given length (values): 1
```

### Solution

Pass the correct number of values to encode.

### Solution

Pass a [valid ABI type](https://docs.soliditylang.org/en/develop/abi-spec.html#types).

## `AbiParameters.SolidityProtectedKeywordError`

## `AbiParameters.ZeroDataError`

Throws when zero data is provided, but data is expected.

### Examples

```ts twoslash
// @noErrors
import { AbiParameters } from 'viem/utils'

AbiParameters.decode([{ type: 'uint256' }], '0x')
//                                           ↑ ❌ zero data
// @error: AbiParameters.DataSizeTooSmallError: Data size of 2 bytes is too small for given parameters.
// @error: Params: (uint256)
// @error: Data:   0x010f (2 bytes)
```

### Solution

Pass valid data.

```ts twoslash
// @noErrors
import { AbiParameters } from 'viem/utils'

AbiParameters.decode(
  [{ type: 'uint256' }],
  '0x00000000000000000000000000000000000000000000000000000000000010f'
)
//                                             ↑ ✅ 32 bytes
```
