# AbiError.encode

ABI-encodes the provided error input (`inputs`), prefixed with the 4 byte error selector.

## Imports

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

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

## Examples

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

const error = AbiError.from(
  'error InvalidSignature(uint r, uint s, uint8 yParity)'
)

const data = AbiError.encode(
  // [!code focus]
  error, // [!code focus]
  [1n, 2n, 0] // [!code focus]
) // [!code focus]
// @log: '0x095ea7b3000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa960450000000000000000000000000000000000000000000000000000000000010f2c'
```

### ABI-shorthand

You can also specify an entire ABI object and an error name as parameters to `AbiError.encode`.

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

const abi = Abi.from([...])

const data = AbiError.encode(
  abi, // [!code hl]
  'InvalidSignature', // [!code hl]
  [1n, 2n, 0]
)
```

## Definition

```ts
function encode<abi, name, args, abiError, allNames>(
  abi: abi | Abi.Abi | readonly unknown[],
  name: Hex.Hex | (name extends allNames ? name : never),
  args: encode.Args<abiError>,
): encode.ReturnType
```

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

## Parameters

### abi

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

### name

* **Type:** `Hex.Hex | (name extends allNames ? name : never)`

### args

* **Type:** `encode.Args<abiError>`

Error arguments

## Return Type

ABI-encoded error name and arguments

`encode.ReturnType`
