Skip to content

encodeAbiParameters

encodeAbiParameters<TParams>(params, values): EncodeAbiParametersReturnType

Type parameters

TParams extends readonly unknown[] | readonly AbiParameter[]

Parameters

params: TParams

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

values: TParams extends readonly AbiParameter[] ? { [K in string | number | symbol]: { [K in string | number | symbol]: AbiParameterToPrimitiveType<TParams<TParams>[K<K>], AbiParameterKind> }[K] } : 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]
)

Source

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