Skip to content

pack

pack(types, values): string

Defined in: utils/solidity-keccak256.ts:118

Converts arrays with types and values into a hex string that can be hashed

Parameters

types

readonly string[]

array of Solidity types, where type[0] is the type for value[0]

values

readonly any[]

array of values, where value[0] is of type type[0]

Returns

string

a hex string with the data given, packed to include its types

Example

const types = ['bool', 'string', 'uint64'];
const values = [true, 'text', 30];
pack(types, values);
// '0x0174657874000000000000001e'