Pre-release — The API surface may change. Unaudited.
Callcium LogoCallcium
API

Descriptor

ABI descriptor model and coder.

Descriptor

Inspect and navigate raw descriptor bytes.

Git Source

Methods

paramCount

Return the declared top-level parameter count.

function paramCount(desc: Uint8Array): number;

Parameters

NameTypeDescription
descUint8Array-

Returns

number

paramOffset

Return byte offset of the N-th top-level param (0-indexed).

function paramOffset(desc: Uint8Array, index: number): number;

Parameters

NameTypeDescription
descUint8Array-
indexnumber-

Returns

number

inspect

Inspect the type node at a given byte offset.

function inspect(desc: Uint8Array, offset: number): TypeInfo;

Parameters

NameTypeDescription
descUint8ArrayRaw descriptor bytes.
offsetnumberByte position of the node.

Returns

TypeInfo — typeCode, isDynamic, and staticSize in bytes.

typeAt

Resolve the type at a calldata path (array of step indices).

The first step selects a top-level param. Each subsequent step descends into the current node: for tuples it selects a field, for arrays it advances to the element descriptor.

function typeAt(desc: Uint8Array, steps: number[]): TypeInfo;

Parameters

NameTypeDescription
descUint8ArrayRaw descriptor bytes.
stepsnumber[]Path steps, length >= 1.

Returns

TypeInfo — TypeInfo for the node at the resolved path.

tupleFieldOffset

Return the byte offset of the fieldIndex-th field inside a tuple node. Starts at the first field and skips fieldIndex nodes using nodeLength.

function tupleFieldOffset(desc: Uint8Array, tupleOffset: number, fieldIndex: number): number;

Parameters

NameTypeDescription
descUint8Array-
tupleOffsetnumber-
fieldIndexnumber-

Returns

number

tupleFieldCount

Return tuple field count at a tuple node offset.

function tupleFieldCount(desc: Uint8Array, offset: number): number;

Parameters

NameTypeDescription
descUint8ArrayRaw descriptor bytes.
offsetnumberByte position of the tuple node.

Returns

number

staticArrayLength

Return static array length at a static array node offset.

function staticArrayLength(desc: Uint8Array, offset: number): number;

Parameters

NameTypeDescription
descUint8ArrayRaw descriptor bytes.
offsetnumberByte position of the static array node.

Returns

number

nodeLength

Return the byte length of the node at offset.

function nodeLength(desc: Uint8Array, offset: number): number;

Parameters

NameTypeDescription
descUint8Array-
offsetnumber-

Returns

number

arrayElementOffset

Return the byte offset of the array element descriptor.

function arrayElementOffset(offset: number): number;

Parameters

NameTypeDescription
offsetnumberByte position of the array node (static or dynamic).

Returns

number

walkPath

Resolve the type at the path and the declared length of the static array a quantifier step descends into (zero when the path holds no quantifier step over a static array).

function walkPath(desc: Uint8Array, steps: number[]): object;

Parameters

NameTypeDescription
descUint8ArrayRaw descriptor bytes.
stepsnumber[]Path steps, length >= 1.

Returns

object — TypeInfo at the resolved path and the quantified static array length.

compileHint

Compile a calldata rule path into its wire hint block.

function compileHint(desc: Uint8Array, steps: number[]): Uint8Array;

Parameters

NameTypeDescription
descUint8ArrayRaw descriptor bytes.
stepsnumber[]Path steps, length >= 1.

Returns

Uint8Array — The hint block bytes.

DescriptorCoder

Encode and decode descriptors.

Git Source

Methods

fromTypes

Encode a comma-separated list of ABI type strings into a binary descriptor.

function fromTypes(typesCsv: string): Uint8Array;

Parameters

NameTypeDescription
typesCsvstringComma-separated ABI type strings, e.g. "address,uint256,(bool,bytes32)[],string".

Returns

Uint8Array — Binary descriptor bytes starting with the version+paramCount header.

toTypes

Reconstruct a comma-separated list of ABI type strings from a binary descriptor.

Inverse of fromTypes: toTypes(fromTypes(s)) returns s for any valid input.

function toTypes(desc: Uint8Array): string;

Parameters

NameTypeDescription
descUint8ArrayBinary descriptor bytes (with version+paramCount header).

Returns

string — Comma-separated ABI type strings, e.g. "address,uint256,(bool,bytes32)[]".

Types

TypeInfo

Structural type information extracted from a descriptor node.

Git Source

On this page