Descriptor
ABI descriptor model and coder.
Descriptor
Inspect and navigate raw descriptor bytes.
Methods
paramCount
Return paramCount from header byte 1.
function paramCount(desc: Uint8Array): number;Parameters
| Name | Type | Description |
|---|---|---|
desc | Uint8Array | - |
Returns
number
paramOffset
Return byte offset of the N-th top-level param (0-indexed).
function paramOffset(desc: Uint8Array, index: number): number;Parameters
| Name | Type | Description |
|---|---|---|
desc | Uint8Array | - |
index | number | - |
Returns
number
inspect
Inspect the type node at a given byte offset.
function inspect(desc: Uint8Array, offset: number): TypeInfo;Parameters
| Name | Type | Description |
|---|---|---|
desc | Uint8Array | Raw descriptor bytes. |
offset | number | Byte 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
| Name | Type | Description |
|---|---|---|
desc | Uint8Array | Raw descriptor bytes. |
steps | number[] | 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
| Name | Type | Description |
|---|---|---|
desc | Uint8Array | - |
tupleOffset | number | - |
fieldIndex | number | - |
Returns
number
tupleFieldCount
Return tuple field count at a tuple node offset.
function tupleFieldCount(desc: Uint8Array, offset: number): number;Parameters
| Name | Type | Description |
|---|---|---|
desc | Uint8Array | Raw descriptor bytes. |
offset | number | Byte 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
| Name | Type | Description |
|---|---|---|
desc | Uint8Array | Raw descriptor bytes. |
offset | number | Byte position of the static array node. |
Returns
number
nodeLength
Return the byte length of the node at offset.
Elementary nodes occupy exactly one byte; composite nodes encode their
length in the lower 12 bits of the 24-bit meta field.
function nodeLength(desc: Uint8Array, offset: number): number;Parameters
| Name | Type | Description |
|---|---|---|
desc | Uint8Array | - |
offset | number | - |
Returns
number
arrayElementOffset
Return the byte offset of the array element descriptor.
function arrayElementOffset(offset: number): number;Parameters
| Name | Type | Description |
|---|---|---|
offset | number | Byte position of the array node (static or dynamic). |
Returns
number
DescriptorCoder
Encode and decode descriptors.
Methods
fromTypes
Encode a comma-separated list of ABI type strings into a binary descriptor.
function fromTypes(typesCsv: string): Uint8Array;Parameters
| Name | Type | Description |
|---|---|---|
typesCsv | string | Comma-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
| Name | Type | Description |
|---|---|---|
desc | Uint8Array | Binary 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.