Skip to content

encodeAbiParameters

encodeAbiParameters<params>(params, values): EncodeAbiParametersReturnType

Type Parameters

params extends readonly unknown[] | readonly AbiParameter[]

a set of ABI Parameters (params), that can be in the shape of the inputs or outputs attribute of an ABI Item.

Parameters

params: params

values: params extends readonly AbiParameter[] ? { [key in string | number | symbol]: { [key in string | number | symbol]: AbiParameterToPrimitiveType<params<params>[key<key>], AbiParameterKind> }[key] } : never

a set of values (values) that correspond to the given params.

Returns

EncodeAbiParametersReturnType

Description

Encodes a list of primitive values into an ABI-encoded hex value.

Examples

import { encodeAbiParameters } from 'viem'
const encodedData = encodeAbiParameters(
[
{ name: 'x', type: 'string' },
{ name: 'y', type: 'uint' },
{ name: 'z', type: 'bool' }
],
['wagmi', 420n, true]
)

You can also pass in Human Readable parameters with the parseAbiParameters utility.

import { encodeAbiParameters, parseAbiParameters } from 'viem'
const encodedData = encodeAbiParameters(
parseAbiParameters('string x, uint y, bool z'),
['wagmi', 420n, true]
)

Defined in

node_modules/.pnpm/viem@2.21.1_bufferutil@4.0.8_typescript@5.6.2_utf-8-validate@6.0.4_zod@3.23.8/node_modules/viem/_types/utils/abi/encodeAbiParameters.d.ts:49