parseAbiParams

Converts an array of parameter values to their respective types based on the provided type array.

This utility function is particularly useful for ensuring that parameter values are correctly formatted according to the expected types before they are used in further processing or passed to a Solidity smart contract.

Example

import { parseAbiParams } from "thirdweb/utils";
const example1 = parseAbiParams(
["address", "uint256"],
["0x.....", "1200000"],
); // result: ["0x......", 1200000n]
const example2 = parseAbiParams(
["address", "bool"],
["0x.....", "true"],
); // result: ["0x......", true]
function parseAbiParams(
constructorParamTypes: Array<string>,
constructorParamValues: Array<unknown>,
): Array<string | bigint | boolean>;

Parameters

An array of type strings indicating the expected types of the values, following Solidity type conventions (e.g., "address", "uint256", "bool").

Type

let constructorParamTypes: Array<string>;

An array of values to be converted according to the types.

Type

let constructorParamValues: Array<unknown>;

Returns

let returnType: Array<string | bigint | boolean>;
  • An array of values converted to their respective types.