Skip to content

AbiParameters.encode

Encodes primitive values into ABI encoded data as per the Application Binary Interface (ABI) Specification.

Imports

Named
import { AbiParameters } from 'ox'

Examples

import { AbiParameters } from 'ox'
 
const data = AbiParameters.encode(
  AbiParameters.from(['string', 'uint', 'bool']),
  ['wagmi', 420n, true],
)

JSON Parameters

Specify JSON ABI Parameters as schema:

import { AbiParameters } from 'ox'
 
const data = AbiParameters.encode(
  [
    { type: 'string', name: 'name' },
    { type: 'uint', name: 'age' },
    { type: 'bool', name: 'isOwner' },
  ],
  ['wagmi', 420n, true],
)

Definition

function encode<parameters>(
  parameters: parameters,
  values: parameters extends AbiParameters ? internal.ToPrimitiveTypes<parameters> : never,
): Hex.Hex

Source: src/AbiParameters.ts

Parameters

parameters

  • Type: parameters

The set of ABI parameters to encode, in the shape of the inputs or outputs attribute of an ABI Item. These parameters must include valid ABI types.

values

  • Type: parameters extends AbiParameters ? internal.ToPrimitiveTypes<parameters> : never

The set of primitive values that correspond to the ABI types defined in parameters.

Return Type

ABI encoded data.

Hex.Hex

Error Type

AbiParameters.encode.ErrorType