encodeAbiParameters

Encodes the given ABI parameters and values into a hexadecimal string.

Example

import { encodeAbiParameters } from "viem";
const params = [
{ name: "param1", type: "uint256" },
{ name: "param2", type: "string" },
];
const values = [123, "hello"];
const data = encodeAbiParameters(params, values);
console.log(data);
function encodeAbiParameters(params: TParams, values: TParams extends readonly Array<AbiParameter> ? {[key in string | number | symbol] : {[key in string | number | symbol] : AbiParameterToPrimitiveType<TParams<TParams>[key<key>], AbiParameterKind>}[key]} : never) : Hex

Parameters

The ABI parameters.

Type

let params: TParams;

The corresponding values for the ABI parameters.

Type

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

Returns

let returnType: `0x${string}`;
  • The encoded ABI parameters as a hexadecimal string.