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
readonlydecimals:number
family
readonlyfamily: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
| Parameter | Type | Description |
|---|---|---|
message | MessageInput | AnyMessage (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
| Parameter | Type | Description |
|---|---|---|
log | Pick<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
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
| Parameter | Type | Description |
|---|---|---|
extraArgs | BytesLike | Extra 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
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
| Parameter | Type | Description |
|---|---|---|
log | Pick<Log_, "data"> | Chain generic log |
Returns
CCIPMessage | undefined
Decoded CCIP message with merged extraArgs, or undefined if not a CCIP message
Example
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
| Parameter | Type | Description |
|---|---|---|
log | Pick<Log_, "data"> | Chain generic log |
Returns
ExecutionReceipt | undefined
ExecutionReceipt or undefined if not a recognized receipt
Example
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
| Parameter | Type | Description |
|---|---|---|
extraArgs | ExtraArgs | Extra args object to encode |
Returns
string
Encoded hex string
Example
const encoded = EVMChain.encodeExtraArgs({
gasLimit: 200000n,
strict: false,
})
formatAddress()?
optionalformatAddress(address:string):string
Format an address for human-friendly display. Defaults to getAddress if not overridden.
Parameters
| Parameter | Type | Description |
|---|---|---|
address | string | Address string in any recognized format |
Returns
string
Human-friendly address string for display
Example
const display = EVMChain.formatAddress?.(rawAddress) ?? rawAddress
console.log(display)
formatTxHash()?
optionalformatTxHash(hash:string):string
Format a transaction hash for human-friendly display.
Parameters
| Parameter | Type | Description |
|---|---|---|
hash | string | Transaction hash string |
Returns
string
Human-friendly hash string for display
Example
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
| Parameter | Type | Description |
|---|---|---|
url | string | RPC endpoint URL |
ctx? | ChainContext | Optional context with logger and API client configuration |
Returns
Promise<Chain<F>>
Promise resolving to Chain instance
Throws
CCIPChainNotFoundError if chain cannot be identified
Example
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
| Parameter | Type | Description |
|---|---|---|
bytes | BytesLike | Bytes 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
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
| Parameter | Type | Description |
|---|---|---|
lane | Lane | Source, dest and onramp lane info |
ctx? | WithLogger | Context object containing logger |
Returns
LeafHasher
LeafHasher function that takes a message and returns its hash
Throws
CCIPHasherVersionUnsupportedError if hasher version unsupported
Example
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
| Parameter | Type | Description |
|---|---|---|
v | unknown | Value to validate |
Returns
v is string
True if value is a valid transaction hash format
Example
if (EVMChain.isTxHash(userInput)) {
const tx = await chain.getTransaction(userInput)
}
parse()?
optionalparse(data:unknown):Record<string,unknown> |null|undefined
Try to parse an error or bytearray generated by this chain family.
Parameters
| Parameter | Type | Description |
|---|---|---|
data | unknown | Caught object, string or bytearray |
Returns
Record<string, unknown> | null | undefined
Ordered record with messages/properties, or undefined/null if not recognized
Example
try {
await chain.sendMessage(opts)
} catch (err) {
const parsed = EVMChain.parse?.(err)
if (parsed) console.log('Contract error:', parsed)
}
Type Parameters
| Type Parameter | Default type |
|---|---|
F extends ChainFamily | ChainFamily |
Example
// 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...')