Skip to content

AbiError.encode

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

Imports

Named
import { AbiError } from 'ox'

Examples

import { AbiError } from 'ox'
 
const error = AbiError.from(
  'error InvalidSignature(uint r, uint s, uint8 yParity)'
)
 
const data = AbiError.encode(
  error,
  [1n, 2n, 0]
)
'0x095ea7b3000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa960450000000000000000000000000000000000000000000000000000000000010f2c'

ABI-shorthand

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

import { Abi, AbiError } from 'ox'
 
const abi = Abi.from([...])
 
const data = AbiError.encode(
  abi,
  'InvalidSignature',
  [1n, 2n, 0]
)

Definition

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

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