Skip to main content
Version: 1.14.0

Type Alias: ChainStatic<F extends ChainFamily = ChainFamily>

ChainStatic<F extends ChainFamily = ChainFamily> = Function & { decimals: number; family: F; buildMessageForDest: AnyMessage; decodeCommits: { maxSeqNr: bigint; merkleRoot: string; minSeqNr: bigint; onRampAddress: string; sourceChainSelector: bigint; }[] | undefined; decodeExtraArgs: EVMExtraArgsV1 & { _tag: "EVMExtraArgsV1"; } | EVMExtraArgsV1 & { allowOutOfOrderExecution: boolean; } & { _tag: "EVMExtraArgsV2"; } | GenericExtraArgsV3 & { _tag: "GenericExtraArgsV3"; } | SVMExtraArgsV1 & { _tag: "SVMExtraArgsV1"; } | EVMExtraArgsV1 & { allowOutOfOrderExecution: boolean; } & { receiverObjectIds: string[]; tokenReceiver: string; } & { _tag: "SuiExtraArgsV1"; } | undefined; decodeMessage: CCIPMessage | undefined; decodeReceipt: ExecutionReceipt | undefined; encodeExtraArgs: string; formatAddress?: string; formatTxHash?: string; fromUrl: Promise<Chain<F>>; getAddress: string; getDestLeafHasher: LeafHasher; isTxHash: v is string; parse?: Record<string, unknown> | null | undefined; }

Defined in: chain.ts:2696

Static methods and properties available on Chain class constructors.

Type Declaration​

decimals​

readonly decimals: number

family​

readonly family: F

buildMessageForDest()​

buildMessageForDest(message: MessageInput): AnyMessage

Returns a copy of a message, populating missing fields like extraArgs with defaults It's expected to return a message suitable at least for basic token transfers

Parameters​

ParameterTypeDescription
messageMessageInputAnyMessage (from source), containing at least receiver

Returns​

AnyMessage

A message suitable for sendMessage to this destination chain family

decodeCommits()​

decodeCommits(log: Pick<ChainLog, "data">, lane?: Lane<CCIPVersion>): { maxSeqNr: bigint; merkleRoot: string; minSeqNr: bigint; onRampAddress: string; sourceChainSelector: bigint; }[] | undefined

Decode a commit (CommitReportAccepted) event.

Parameters​

ParameterTypeDescription
logPick<ChainLog, "data">Chain generic log
lane?Lane<CCIPVersion>If passed, filter or validate reports by lane

Returns​

{ maxSeqNr: bigint; merkleRoot: string; minSeqNr: bigint; onRampAddress: string; sourceChainSelector: bigint; }[] | undefined

Array of commit reports contained in the log, or undefined

Example​

Decode commit from log

TypeScript
const commits = EVMChain.decodeCommits(log, lane)
if (commits) {
console.log(`Found ${commits.length} commit(s)`)
}

decodeExtraArgs()​

decodeExtraArgs(extraArgs: BytesLike): EVMExtraArgsV1 & { _tag: "EVMExtraArgsV1"; } | EVMExtraArgsV1 & { allowOutOfOrderExecution: boolean; } & { _tag: "EVMExtraArgsV2"; } | GenericExtraArgsV3 & { _tag: "GenericExtraArgsV3"; } | SVMExtraArgsV1 & { _tag: "SVMExtraArgsV1"; } | EVMExtraArgsV1 & { allowOutOfOrderExecution: boolean; } & { receiverObjectIds: string[]; tokenReceiver: string; } & { _tag: "SuiExtraArgsV1"; } | undefined

Try to decode an extraArgs array serialized for this chain family.

Parameters​

ParameterTypeDescription
extraArgsBytesLikeExtra args bytes (Uint8Array, HexString or base64)

Returns​

Object containing decoded extraArgs and their tag, or undefined

EVMExtraArgsV1 & { _tag: "EVMExtraArgsV1"; }


EVMExtraArgsV1 & { allowOutOfOrderExecution: boolean; } & { _tag: "EVMExtraArgsV2"; }


GenericExtraArgsV3 & { _tag: "GenericExtraArgsV3"; }


SVMExtraArgsV1 & { _tag: "SVMExtraArgsV1"; }


EVMExtraArgsV1 & { allowOutOfOrderExecution: boolean; } & { receiverObjectIds: string[]; tokenReceiver: string; } & { _tag: "SuiExtraArgsV1"; }


undefined

Throws​

CCIPExtraArgsParseError if bytes cannot be decoded

Example​

Decode extra args

TypeScript
const decoded = EVMChain.decodeExtraArgs(message.extraArgs)
if (decoded?._tag === 'EVMExtraArgsV2') {
console.log(`Gas limit: ${decoded.gasLimit}`)
}

decodeMessage()​

decodeMessage(log: Pick<ChainLog, "data">): CCIPMessage | undefined

Try to decode a CCIP message from a log/event originated from this source chain. The parsing is specific to this chain family, but content may target other chains.

Parameters​

ParameterTypeDescription
logPick<ChainLog, "data">Chain generic log

Returns​

CCIPMessage | undefined

Decoded CCIP message with merged extraArgs, or undefined if not a CCIP message

Example​

Decode message from log

TypeScript
const message = EVMChain.decodeMessage(log)
if (message) {
console.log(`Message ID: ${message.messageId}`)
}

decodeReceipt()​

decodeReceipt(log: Pick<ChainLog, "data">): ExecutionReceipt | undefined

Decode a receipt (ExecutionStateChanged) event.

Parameters​

ParameterTypeDescription
logPick<ChainLog, "data">Chain generic log

Returns​

ExecutionReceipt | undefined

ExecutionReceipt or undefined if not a recognized receipt

Example​

Decode execution receipt

TypeScript
const receipt = EVMChain.decodeReceipt(log)
if (receipt) {
console.log(`State: ${receipt.state}, Message: ${receipt.messageId}`)
}

encodeExtraArgs()​

encodeExtraArgs(extraArgs: ExtraArgs): string

Encode extraArgs for this chain family.

Parameters​

ParameterTypeDescription
extraArgsExtraArgsExtra args object to encode

Returns​

string

Encoded hex string

Example​

Encode extra args

TypeScript
const encoded = EVMChain.encodeExtraArgs({
gasLimit: 200000n,
strict: false,
})

formatAddress()?​

optional formatAddress(address: string): string

Format an address for human-friendly display. Defaults to getAddress if not overridden.

Parameters​

ParameterTypeDescription
addressstringAddress string in any recognized format

Returns​

string

Human-friendly address string for display

Example​

Format address for display

TypeScript
const display = EVMChain.formatAddress?.(rawAddress) ?? rawAddress
console.log(display)

formatTxHash()?​

optional formatTxHash(hash: string): string

Format a transaction hash for human-friendly display.

Parameters​

ParameterTypeDescription
hashstringTransaction hash string

Returns​

string

Human-friendly hash string for display

Example​

Format tx hash for display

TypeScript
const display = EVMChain.formatTxHash?.(rawHash) ?? rawHash
console.log(display)

fromUrl()​

fromUrl(url: string, ctx?: ChainContext): Promise<Chain<F>>

Async constructor: builds a Chain from an RPC endpoint URL.

Parameters​

ParameterTypeDescription
urlstringRPC endpoint URL
ctx?ChainContextOptional context with logger and API client configuration

Returns​

Promise<Chain<F>>

Promise resolving to Chain instance

Throws​

CCIPChainNotFoundError if chain cannot be identified

Example​

Create chain from RPC

TypeScript
const chain = await EVMChain.fromUrl('https://eth-mainnet.example.com')
console.log(`Connected to: ${chain.network.name}`)

getAddress()​

getAddress(bytes: BytesLike): string

Receive a bytes array and try to decode and normalize it as an address of this chain family.

Parameters​

ParameterTypeDescription
bytesBytesLikeBytes array (Uint8Array, HexString or Base64)

Returns​

string

Address in this chain family's format

Throws​

CCIPAddressInvalidEvmError if invalid EVM address

Throws​

CCIPDataFormatUnsupportedError if invalid Aptos/Sui address

Example​

Normalize address

TypeScript
const normalized = EVMChain.getAddress('0xABC123...')
console.log(normalized) // checksummed address

getDestLeafHasher()​

getDestLeafHasher(lane: Lane, ctx?: WithLogger): LeafHasher

Create a leaf hasher for this dest chain and lane.

Parameters​

ParameterTypeDescription
laneLaneSource, dest and onramp lane info
ctx?WithLoggerContext object containing logger

Returns​

LeafHasher

LeafHasher function that takes a message and returns its hash

Throws​

CCIPHasherVersionUnsupportedError if hasher version unsupported

Example​

Create leaf hasher

TypeScript
const hasher = EVMChain.getDestLeafHasher(lane, { logger })
const leafHash = hasher(message)

isTxHash()​

isTxHash(v: unknown): v is string

Validates a transaction hash format for this chain family.

Parameters​

ParameterTypeDescription
vunknownValue to validate

Returns​

v is string

True if value is a valid transaction hash format

Example​

Validate transaction hash

TypeScript
if (EVMChain.isTxHash(userInput)) {
const tx = await chain.getTransaction(userInput)
}

parse()?​

optional parse(data: unknown): Record<string, unknown> | null | undefined

Try to parse an error or bytearray generated by this chain family.

Parameters​

ParameterTypeDescription
dataunknownCaught object, string or bytearray

Returns​

Record<string, unknown> | null | undefined

Ordered record with messages/properties, or undefined/null if not recognized

Example​

Parse contract error

TypeScript
try {
await chain.sendMessage(opts)
} catch (err) {
const parsed = EVMChain.parse?.(err)
if (parsed) console.log('Contract error:', parsed)
}

Type Parameters​

Type ParameterDefault type
F extends ChainFamilyChainFamily

Example​

Using static methods

TypeScript
// Create chain from URL
const chain = await EVMChain.fromUrl('https://eth-mainnet.example.com')

// Decode message from log
const message = EVMChain.decodeMessage(log)

// Validate address format
const normalized = EVMChain.getAddress('0xABC...')