Skip to main content
Version: 0.96.0

Type Alias: ChainStatic<F>

ChainStatic<F> = 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:1346

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<Log_, "data">, lane?: Lane<CCIPVersion>): { maxSeqNr: bigint; merkleRoot: string; minSeqNr: bigint; onRampAddress: string; sourceChainSelector: bigint; }[] | undefined

Decode a commit (CommitReportAccepted) event.

Parameters

ParameterTypeDescription
logPick<Log_, "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

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

EVMExtraArgsV1 & { _tag: "EVMExtraArgsV1"; }

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

GenericExtraArgsV3 & { _tag: "GenericExtraArgsV3"; }

SVMExtraArgsV1 & { _tag: "SVMExtraArgsV1"; }

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

undefined

Object containing decoded extraArgs and their tag, or undefined

Throws

CCIPExtraArgsParseError if bytes cannot be decoded

Example

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

decodeMessage()

decodeMessage(log: Pick<Log_, "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<Log_, "data">Chain generic log

Returns

CCIPMessage | undefined

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

Example

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

decodeReceipt()

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

Decode a receipt (ExecutionStateChanged) event.

Parameters

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

Returns

ExecutionReceipt | undefined

ExecutionReceipt or undefined if not a recognized receipt

Example

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

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

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

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

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

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

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

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

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

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...')