Skip to main content
Version: 0.96.0

Abstract Interface: Chain<F>

Defined in: chain.ts:322

Works like an interface for a base Chain class, but provides implementation (which can be specialized) for some basic methods

Extended by

Type Parameters

Type ParameterDefault type
F extends ChainFamilyChainFamily

Indexable

[key: symbol]: () => string

Properties

apiClient

readonly apiClient: CCIPAPIClient | null

Defined in: chain.ts:326

CCIP API client (null if opted out)


apiRetryConfig

readonly apiRetryConfig: Required<ApiRetryConfig> | null

Defined in: chain.ts:328

Retry configuration for API fallback operations (null if API client is disabled)


logger

logger: Logger

Defined in: chain.ts:324


network

readonly network: NetworkInfo<F>

Defined in: chain.ts:323

Methods

destroy()?

optional destroy(): void | Promise<void>

Defined in: chain.ts:362

Cleanup method to release resources (e.g., close connections).

Returns

void | Promise<void>


estimateReceiveExecution()?

optional estimateReceiveExecution(opts: { message: { data?: BytesLike; destTokenAmounts?: readonly { amount: bigint; token: string; }[]; messageId: string; sender?: string; sourceChainSelector: bigint; }; offRamp: string; receiver: string; }): Promise<number>

Defined in: chain.ts:1308

Estimate ccipReceive execution cost (gas, computeUnits) for this dest

Parameters

ParameterTypeDescription
opts{ message: { data?: BytesLike; destTokenAmounts?: readonly { amount: bigint; token: string; }[]; messageId: string; sender?: string; sourceChainSelector: bigint; }; offRamp: string; receiver: string; }estimation options
opts.message{ data?: BytesLike; destTokenAmounts?: readonly { amount: bigint; token: string; }[]; messageId: string; sender?: string; sourceChainSelector: bigint; }-
opts.message.data?BytesLike-
opts.message.destTokenAmounts?readonly { amount: bigint; token: string; }[]-
opts.message.messageIdstring-
opts.message.sender?string-
opts.message.sourceChainSelectorbigint-
opts.offRampstring-
opts.receiverstring-

Returns

Promise<number>

estimated execution cost (gas or computeUnits)


executeReport()

abstract executeReport(opts: ExecuteReportOpts & { wallet: unknown; }): Promise<CCIPExecution>

Defined in: chain.ts:943

Execute messages in report in an offRamp.

Parameters

ParameterTypeDescription
optsExecuteReportOpts & { wallet: unknown; }ExecuteReportOpts with chain-specific wallet to sign and send tx

Returns

Promise<CCIPExecution>

Promise resolving to transaction of the execution

Throws

CCIPWalletNotSignerError if wallet is not a valid signer

Throws

CCIPExecTxRevertedError if execution transaction reverts

Throws

CCIPMerkleRootMismatchError if merkle proof is invalid

Example

TypeScript
const execReportProof = calculateManualExecProof(
messagesInBatch: await source.getMessagesInBatch(request, commit.report),
request.lane,
request.message.messageId,
commit.report.merkleRoot,
dest,
)
const receipt = await dest.executeReport({
offRamp,
execReport: {
...execReportProof,
message: request.message,
offchainTokenData: await source.getOffchainTokenData(request),
},
wallet,
})
console.log(`Executed: ${receipt.log.transactionHash}`)

Throws

CCIPWalletNotSignerError if wallet cannot sign transactions

Throws

CCIPExecTxNotConfirmedError if execution transaction fails to confirm


generateUnsignedExecuteReport()

abstract generateUnsignedExecuteReport(opts: ExecuteReportOpts & { payer: string; }): Promise<UnsignedTx[F]>

Defined in: chain.ts:904

Generate unsigned tx to manuallyExecute a message.

Parameters

ParameterTypeDescription
optsExecuteReportOpts & { payer: string; }ExecuteReportOpts with payer address which will send the exec tx

Returns

Promise<UnsignedTx[F]>

Promise resolving to chain-family specific unsigned txs

Example

TypeScript
const unsignedTx = await dest.generateUnsignedExecuteReport({
offRamp: offRampAddress,
execReport,
payer: walletAddress,
})
// Sign and send with external wallet

generateUnsignedSendMessage()

abstract generateUnsignedSendMessage(opts: SendMessageOpts & { sender: string; }): Promise<UnsignedTx[F]>

Defined in: chain.ts:835

Generate unsigned txs for ccipSend'ing a message.

Parameters

ParameterTypeDescription
optsSendMessageOpts & { sender: string; }SendMessageOpts with sender address

Returns

Promise<UnsignedTx[F]>

Promise resolving to chain-family specific unsigned txs

Example

TypeScript
const unsignedTx = await chain.generateUnsignedSendMessage({
router: routerAddress,
destChainSelector: destSelector,
message: { receiver: '0x...', data: '0x1337' },
sender: walletAddress,
})
// Sign and send with external wallet

getBalance()

abstract getBalance(opts: GetBalanceOpts): Promise<bigint>

Defined in: chain.ts:786

Query token balance for an address.

Parameters

ParameterTypeDescription
optsGetBalanceOptsBalance query options

Returns

Promise<bigint>

Token balance information including raw and formatted values

Throws

CCIPNotImplementedError if chain family doesn't support this method

Examples

TypeScript
const balance = await chain.getBalance({ holder: '0x123...' })
console.log(`Native balance: ${balance}`) // balance in wei
TypeScript
const balance = await chain.getBalance({
holder: '0x123...',
token: '0xLINK...'
})
console.log(`LINK balance: ${balance}`) // balance in smallest units

getBlockTimestamp()

abstract getBlockTimestamp(block: number | "finalized"): Promise<number>

Defined in: chain.ts:384

Fetch the timestamp of a given block.

Parameters

ParameterTypeDescription
blocknumber | "finalized"Positive block number, negative finality depth, or 'finalized' tag

Returns

Promise<number>

Promise resolving to timestamp of the block, in seconds

Throws

CCIPBlockNotFoundError if block does not exist

Example

TypeScript
const chain = await EVMChain.fromUrl('https://eth-mainnet.example.com')
const timestamp = await chain.getBlockTimestamp('finalized')
console.log(`Finalized at: ${new Date(timestamp * 1000).toISOString()}`)

getCommitReport()

getCommitReport(opts: { commitStore: string; request: { lane: Lane<CCIPVersion>; message: { sequenceNumber: bigint; } | { sequenceNumber: bigint; } | { sequenceNumber: bigint; } | { sequenceNumber: bigint; } | { sequenceNumber: bigint; }; tx: { timestamp: number; }; }; } & Pick<LogFilter, "startBlock" | "watch" | "page">): Promise<CCIPCommit>

Defined in: chain.ts:968

Look for a CommitReport at dest for given CCIP request. May be specialized by some subclasses.

Parameters

ParameterTypeDescription
opts{ commitStore: string; request: { lane: Lane<CCIPVersion>; message: { sequenceNumber: bigint; } | { sequenceNumber: bigint; } | { sequenceNumber: bigint; } | { sequenceNumber: bigint; } | { sequenceNumber: bigint; }; tx: { timestamp: number; }; }; } & Pick<LogFilter, "startBlock" | "watch" | "page">getCommitReport options

Returns

Promise<CCIPCommit>

CCIPCommit info

Throws

CCIPCommitNotFoundError if no commit found for the request (transient)

Example

TypeScript
const commit = await dest.getCommitReport({
commitStore: offRampAddress, // v1.6+
request,
})
console.log(`Committed at block: ${commit.log.blockNumber}`)

getCommitStoreForOffRamp()

abstract getCommitStoreForOffRamp(offRamp: string): Promise<string>

Defined in: chain.ts:737

Fetch the CommitStore set in OffRamp config (CCIP v1.5 and earlier). For CCIP v1.6 and later, it should return the offRamp address.

Parameters

ParameterTypeDescription
offRampstringOffRamp contract address

Returns

Promise<string>

Promise resolving to CommitStore address

Example

TypeScript
const commitStore = await dest.getCommitStoreForOffRamp(offRampAddress)
// For v1.6+, commitStore === offRampAddress

getExecutionReceipts()

getExecutionReceipts(opts: { commit?: CCIPCommit; messageId?: string; offRamp: string; sourceChainSelector?: bigint; } & Pick<LogFilter, "startBlock" | "startTime" | "watch" | "page">): AsyncIterableIterator<CCIPExecution>

Defined in: chain.ts:1039

Default/generic implementation of getExecutionReceipts. Yields execution receipts for a given offRamp.

Parameters

ParameterTypeDescription
opts{ commit?: CCIPCommit; messageId?: string; offRamp: string; sourceChainSelector?: bigint; } & Pick<LogFilter, "startBlock" | "startTime" | "watch" | "page">getExecutionReceipts options

Returns

AsyncIterableIterator<CCIPExecution>

Async generator of CCIPExecution receipts

Example

TypeScript
for await (const exec of dest.getExecutionReceipts({
offRamp: offRampAddress,
messageId: request.message.messageId,
startBlock: commit.log.blockNumber,
})) {
console.log(`State: ${exec.receipt.state}`)
if (exec.receipt.state === ExecutionState.Success) break
}

getFee()

abstract getFee(opts: Omit<SendMessageOpts, "approveMax">): Promise<bigint>

Defined in: chain.ts:817

Fetch the current fee for a given intended message.

Parameters

ParameterTypeDescription
optsOmit<SendMessageOpts, "approveMax">SendMessageOpts without approveMax

Returns

Promise<bigint>

Fee amount in the feeToken's smallest units

Example

TypeScript
const fee = await chain.getFee({
router: routerAddress,
destChainSelector: destSelector,
message: { receiver: '0x...', data: '0x' },
})
console.log(`Fee: ${fee} wei`)

getFeeTokens()

abstract getFeeTokens(router: string): Promise<Record<string, TokenInfo>>

Defined in: chain.ts:1265

Fetch list and info of supported feeTokens.

Parameters

ParameterTypeDescription
routerstringRouter address on this chain

Returns

Promise<Record<string, TokenInfo>>

Promise resolving to mapping of token addresses to TokenInfo objects

Example

TypeScript
const feeTokens = await chain.getFeeTokens(routerAddress)
for (const [addr, info] of Object.entries(feeTokens)) {
console.log(`${info.symbol}: ${addr}`)
}

getLaneLatency()

getLaneLatency(destChainSelector: bigint): Promise<LaneLatencyResponse>

Defined in: chain.ts:1013

Fetches estimated lane latency to a destination chain. Uses this chain's selector as the source.

Parameters

ParameterTypeDescription
destChainSelectorbigintDestination CCIP chain selector (bigint)

Returns

Promise<LaneLatencyResponse>

Promise resolving to LaneLatencyResponse containing:

  • lane.sourceNetworkInfo - Source chain metadata (name, selector, chainId)
  • lane.destNetworkInfo - Destination chain metadata
  • lane.routerAddress - Router contract address on source chain
  • totalMs - Estimated delivery time in milliseconds

Throws

CCIPApiClientNotAvailableError if apiClient was disabled (set to null)

Throws

CCIPHttpError if API request fails (network error, 4xx, 5xx status)

Remarks

Each call makes a fresh API request. Consider caching results if making frequent calls for the same lane.

Example

TypeScript
const chain = await EVMChain.fromUrl('https://eth-mainnet.example.com')
try {
const latency = await chain.getLaneLatency(4949039107694359620n) // Arbitrum
console.log(`Estimated delivery: ${Math.round(latency.totalMs / 60000)} minutes`)
console.log(`Router: ${latency.lane.routerAddress}`)
} catch (err) {
if (err instanceof CCIPHttpError) {
console.error(`API error: ${err.context.apiErrorCode}`)
}
}

getLogs()

abstract getLogs(opts: LogFilter): AsyncIterableIterator<Log_>

Defined in: chain.ts:492

An async generator that yields logs based on the provided options.

Parameters

ParameterTypeDescription
optsLogFilterOptions object containing: - startBlock: if provided, fetch and generate logs forward starting from this block; otherwise, returns logs backwards in time from endBlock; optionally, startTime may be provided to fetch logs forward starting from this time - startTime: instead of a startBlock, a start timestamp may be provided; if either is provided, fetch logs forward from this starting point; otherwise, backwards - endBlock: if omitted, use latest block; can be a block number, 'latest', 'finalized' or negative finality block depth - endBefore: optional hint signature for end of iteration, instead of endBlock - address: if provided, fetch logs for this address only (may be required in some networks/implementations) - topics: if provided, fetch logs for these topics only; if string[], it's assumed to be a list of topic0s (i.e. string[] or string[][0], event_ids); some networks/implementations may not be able to filter topics other than topic0s, so one may want to assume those are optimization hints, instead of hard filters, and verify results - page: if provided, try to use this page/range for batches - watch: true or cancellation promise, getLogs continuously after initial fetch

Returns

AsyncIterableIterator<Log_>

An async iterable iterator of logs.

Throws

CCIPLogsWatchRequiresFinalityError if watch mode is used without a finality endBlock tag

Throws

CCIPLogsWatchRequiresStartError if watch mode is used without startBlock or startTime

Throws

CCIPLogsAddressRequiredError if address is required but not provided (chain-specific)


getMessageById()

getMessageById(messageId: string, _opts?: { onRamp?: string; page?: number; }): Promise<CCIPRequest<CCIPVersion>>

Defined in: chain.ts:568

Fetch a CCIP message by its unique message ID.

Parameters

ParameterTypeDescription
messageIdstringThe unique message ID (0x + 64 hex chars)
_opts?{ onRamp?: string; page?: number; }Optional: onRamp hint for non-EVM chains
_opts.onRamp?string-
_opts.page?number-

Returns

Promise<CCIPRequest<CCIPVersion>>

CCIPRequest with metadata populated from API

Remarks

Uses the CCIP API to retrieve message details. The returned request includes a metadata field with API-specific information.

Example

TypeScript
const request = await chain.getMessageById(messageId)
console.log(`Sender: ${request.message.sender}`)

if (request.metadata) {
console.log(`Status: ${request.metadata.status}`)
if (request.metadata.deliveryTime) {
console.log(`Delivered in ${request.metadata.deliveryTime}ms`)
}
}

Throws

CCIPApiClientNotAvailableError if API disabled

Throws

CCIPMessageIdNotFoundError if message not found

Throws

CCIPOnRampRequiredError if onRamp is required but not provided

Throws

CCIPHttpError if API request fails


getMessagesInBatch()

abstract getMessagesInBatch<R>(request: R, commit: Pick<CommitReport, "minSeqNr" | "maxSeqNr">, opts?: { page?: number; }): Promise<R["message"][]>

Defined in: chain.ts:597

Fetches all CCIP messages contained in a given commit batch.

Type Parameters

Type Parameter
R extends { lane: Lane<CCIPVersion>; log: { } & { } & { }; message: { sequenceNumber: bigint; } | { sequenceNumber: bigint; } | { sequenceNumber: bigint; } | { sequenceNumber: bigint; } | { sequenceNumber: bigint; }; }

Parameters

ParameterTypeDescription
requestRCCIPRequest to fetch batch for
commitPick<CommitReport, "minSeqNr" | "maxSeqNr">CommitReport range (min, max)
opts?{ page?: number; }Optional parameters (e.g., page for pagination width)
opts.page?number-

Returns

Promise<R["message"][]>

Array of messages in the batch

Throws

CCIPMessageBatchIncompleteError if not all messages in range could be fetched

Example

TypeScript
const commit = await dest.getCommitReport({ commitStore, request })
const messages = await source.getMessagesInBatch(request, commit.report)
console.log(`Found ${messages.length} messages in batch`)

getMessagesInTx()

getMessagesInTx(tx: string | ChainTransaction): Promise<CCIPRequest<CCIPVersion>[]>

Defined in: chain.ts:512

Fetch all CCIP requests in a transaction.

Parameters

ParameterTypeDescription
txstring | ChainTransactionChainTransaction or txHash to fetch requests from

Returns

Promise<CCIPRequest<CCIPVersion>[]>

Promise resolving to CCIP messages in the transaction (at least one)

Throws

CCIPTransactionNotFoundError if transaction does not exist

Throws

CCIPMessageNotFoundInTxError if no CCIPSendRequested events in tx

Example

TypeScript
const chain = await EVMChain.fromUrl('https://eth-mainnet.example.com')
const requests = await chain.getMessagesInTx('0xabc123...')
for (const req of requests) {
console.log(`Message ID: ${req.message.messageId}`)
}

getNativeTokenForRouter()

abstract getNativeTokenForRouter(router: string): Promise<string>

Defined in: chain.ts:677

Get the native token address for a Router.

Parameters

ParameterTypeDescription
routerstringRouter contract address

Returns

Promise<string>

Promise resolving to native token address (usually wrapped)

Example

TypeScript
const weth = await chain.getNativeTokenForRouter(routerAddress)
console.log(`Wrapped native: ${weth}`)

getOffchainTokenData()

abstract getOffchainTokenData(request: CCIPRequest): Promise<OffchainTokenData[]>

Defined in: chain.ts:887

Fetch supported offchain token data for a request from this network.

Parameters

ParameterTypeDescription
requestCCIPRequestCCIP request, with tx, logs and message

Returns

Promise<OffchainTokenData[]>

Promise resolving to array with one offchain token data for each token transfer

Throws

CCIPUsdcAttestationError if USDC attestation fetch fails (transient)

Throws

CCIPLbtcAttestationError if LBTC attestation fetch fails (transient)

Example

TypeScript
const offchainData = await source.getOffchainTokenData(request)
// Use in execution report

getOffRampsForRouter()

abstract getOffRampsForRouter(router: string, sourceChainSelector: bigint): Promise<string[]>

Defined in: chain.ts:692

Fetch the OffRamps allowlisted in a Router. Used to discover OffRamp connected to an OnRamp.

Parameters

ParameterTypeDescription
routerstringRouter contract address
sourceChainSelectorbigintSource chain selector

Returns

Promise<string[]>

Promise resolving to array of OffRamp addresses

Example

TypeScript
const offRamps = await dest.getOffRampsForRouter(routerAddress, sourceSelector)
console.log(`Found ${offRamps.length} offRamp(s)`)

getOnRampForOffRamp()

abstract getOnRampForOffRamp(offRamp: string, sourceChainSelector: bigint): Promise<string>

Defined in: chain.ts:723

Fetch the OnRamp address set in OffRamp config. Used to discover OffRamp connected to an OnRamp.

Parameters

ParameterTypeDescription
offRampstringOffRamp contract address
sourceChainSelectorbigintSource chain selector

Returns

Promise<string>

Promise resolving to OnRamp address

Example

TypeScript
const onRamp = await dest.getOnRampForOffRamp(offRampAddress, sourceSelector)
console.log(`OnRamp: ${onRamp}`)

getOnRampForRouter()

abstract getOnRampForRouter(router: string, destChainSelector: bigint): Promise<string>

Defined in: chain.ts:708

Fetch the OnRamp registered in a Router for a destination chain.

Parameters

ParameterTypeDescription
routerstringRouter contract address
destChainSelectorbigintDestination chain selector

Returns

Promise<string>

Promise resolving to OnRamp address

Throws

CCIPLaneNotFoundError if no lane exists to destination

Example

TypeScript
const onRamp = await source.getOnRampForRouter(routerAddress, destSelector)
console.log(`OnRamp: ${onRamp}`)

getRegistryTokenConfig()

abstract getRegistryTokenConfig(registry: string, token: string): Promise<RegistryTokenConfig>

Defined in: chain.ts:1145

Fetch token configuration from a TokenAdminRegistry.

Parameters

ParameterTypeDescription
registrystringTokenAdminRegistry contract address.
tokenstringToken address to query.

Returns

Promise<RegistryTokenConfig>

RegistryTokenConfig containing administrator and pool information.

Remarks

The TokenAdminRegistry is a contract that tracks token administrators and their associated pools. Each token has an administrator who can update pool configurations.

Example

TypeScript
const config = await chain.getRegistryTokenConfig(registryAddress, tokenAddress)
console.log(`Administrator: ${config.administrator}`)
if (config.tokenPool) {
console.log(`Pool: ${config.tokenPool}`)
}

Throws

CCIPTokenNotInRegistryError if token is not registered.


getRouterForOffRamp()

abstract getRouterForOffRamp(offRamp: string, sourceChainSelector: bigint): Promise<string>

Defined in: chain.ts:664

Fetch the Router address set in OffRamp config.

Parameters

ParameterTypeDescription
offRampstringOffRamp contract address
sourceChainSelectorbigintSource chain selector

Returns

Promise<string>

Promise resolving to Router address

Throws

CCIPContractTypeInvalidError if address is not an OffRamp

Example

TypeScript
const router = await chain.getRouterForOffRamp(offRampAddress, sourceSelector)
console.log(`Router: ${router}`)

getRouterForOnRamp()

abstract getRouterForOnRamp(onRamp: string, destChainSelector: bigint): Promise<string>

Defined in: chain.ts:648

Fetch the Router address set in OnRamp config. Used to discover OffRamp connected to OnRamp.

Parameters

ParameterTypeDescription
onRampstringOnRamp contract address
destChainSelectorbigintDestination chain selector

Returns

Promise<string>

Promise resolving to Router address

Throws

CCIPContractTypeInvalidError if address is not an OnRamp

Example

TypeScript
const router = await chain.getRouterForOnRamp(onRampAddress, destSelector)
console.log(`Router: ${router}`)

getSupportedTokens()

abstract getSupportedTokens(address: string, opts?: { page?: number; }): Promise<string[]>

Defined in: chain.ts:1122

List tokens supported by given TokenAdminRegistry contract.

Parameters

ParameterTypeDescription
addressstringUsually TokenAdminRegistry, but chain may support receiving Router, OnRamp, etc.
opts?{ page?: number; }Optional parameters (e.g., page for pagination range)
opts.page?number-

Returns

Promise<string[]>

Promise resolving to array of supported token addresses

Example

TypeScript
const tokens = await chain.getSupportedTokens(registryAddress)
console.log(`${tokens.length} tokens supported`)

getTokenAdminRegistryFor()

abstract getTokenAdminRegistryFor(address: string): Promise<string>

Defined in: chain.ts:800

Fetch TokenAdminRegistry configured in a given OnRamp, Router, etc. Needed to map a source token to its dest counterparts.

Parameters

ParameterTypeDescription
addressstringContract address (OnRamp, Router, etc.)

Returns

Promise<string>

Promise resolving to TokenAdminRegistry address

Example

TypeScript
const registry = await chain.getTokenAdminRegistryFor(onRampAddress)
console.log(`Registry: ${registry}`)

getTokenForTokenPool()

abstract getTokenForTokenPool(tokenPool: string): Promise<string>

Defined in: chain.ts:750

Fetch the TokenPool's token/mint.

Parameters

ParameterTypeDescription
tokenPoolstringTokenPool address

Returns

Promise<string>

Promise resolving to token or mint address

Example

TypeScript
const token = await chain.getTokenForTokenPool(tokenPoolAddress)
console.log(`Token: ${token}`)

getTokenInfo()

abstract getTokenInfo(token: string): Promise<TokenInfo>

Defined in: chain.ts:763

Fetch token metadata.

Parameters

ParameterTypeDescription
tokenstringToken address

Returns

Promise<TokenInfo>

Promise resolving to token symbol, decimals, and optionally name

Example

TypeScript
const info = await chain.getTokenInfo(tokenAddress)
console.log(`${info.symbol}: ${info.decimals} decimals`)

getTokenPoolConfig()

abstract getTokenPoolConfig(tokenPool: string): Promise<TokenPoolConfig>

Defined in: chain.ts:1173

Fetch configuration of a token pool.

Parameters

ParameterTypeDescription
tokenPoolstringToken pool contract address.

Returns

Promise<TokenPoolConfig>

TokenPoolConfig containing token, router, and version info.

Remarks

Return type varies by chain:

  • EVM: typeAndVersion is always present (required)
  • Solana: Includes extra tokenPoolProgram field
  • Aptos: Standard fields only
  • Sui/TON: Throws CCIPNotImplementedError

Example

TypeScript
// Use instanceof to narrow the chain type
if (chain instanceof SolanaChain) {
const config = await chain.getTokenPoolConfig(poolAddress)
console.log(config.tokenPoolProgram) // TypeScript knows this exists!
} else if (chain instanceof EVMChain) {
const config = await chain.getTokenPoolConfig(poolAddress)
console.log(config.typeAndVersion) // TypeScript knows this is required!
}

Throws

CCIPNotImplementedError on Sui or TON chains


getTokenPoolRemote()

getTokenPoolRemote(tokenPool: string, remoteChainSelector: bigint): Promise<TokenPoolRemote>

Defined in: chain.ts:1238

Fetch remote chain configuration for a token pool for a specific destination.

Parameters

ParameterTypeDescription
tokenPoolstringToken pool address on the current chain.
remoteChainSelectorbigintChain selector of the desired remote chain.

Returns

Promise<TokenPoolRemote>

TokenPoolRemote config for the specified remote chain.

Remarks

Convenience wrapper around getTokenPoolRemotes that returns a single configuration instead of a Record. Use this when you need configuration for a specific destination chain.

Example

TypeScript
const arbitrumSelector = 4949039107694359620n
const remote = await chain.getTokenPoolRemote(poolAddress, arbitrumSelector)
console.log(`Remote token: ${remote.remoteToken}`)
console.log(`Remote pools: ${remote.remotePools.join(', ')}`)

Throws

CCIPTokenPoolChainConfigNotFoundError if no configuration found for the specified remote chain.


getTokenPoolRemotes()

abstract getTokenPoolRemotes(tokenPool: string, remoteChainSelector?: bigint): Promise<Record<string, TokenPoolRemote>>

Defined in: chain.ts:1213

Fetch remote chain configurations for a token pool.

Parameters

ParameterTypeDescription
tokenPoolstringToken pool address on the current chain.
remoteChainSelector?bigintOptional chain selector to filter results to a single destination.

Returns

Promise<Record<string, TokenPoolRemote>>

Record where keys are chain names (e.g., "ethereum-mainnet") and values are TokenPoolRemote configs.

Remarks

A token pool maintains configurations for each destination chain it supports. The returned Record maps chain names to their respective configurations.

Examples

TypeScript
const remotes = await chain.getTokenPoolRemotes(poolAddress)
// Returns: {
// "ethereum-mainnet": { remoteToken: "0x...", remotePools: [...], ... },
// "ethereum-mainnet-arbitrum-1": { remoteToken: "0x...", remotePools: [...], ... },
// "solana-mainnet": { remoteToken: "...", remotePools: [...], ... }
// }

// Access a specific chain's config
const arbConfig = remotes['ethereum-mainnet']
console.log(`Remote token: ${arbConfig.remoteToken}`)
TypeScript
import { networkInfo } from '@chainlink/ccip-sdk'

const arbitrumSelector = 4949039107694359620n
const remotes = await chain.getTokenPoolRemotes(poolAddress, arbitrumSelector)
// Returns only: { "arbitrum-mainnet": { ... } }

const chainName = networkInfo(arbitrumSelector).name
const config = remotes[chainName]

Throws

CCIPTokenPoolChainConfigNotFoundError if remoteChainSelector is specified but not configured.


getTransaction()

abstract getTransaction(hash: string): Promise<ChainTransaction>

Defined in: chain.ts:406

Fetch a transaction by its hash.

Parameters

ParameterTypeDescription
hashstringTransaction hash

Returns

Promise<ChainTransaction>

Promise resolving to generic transaction details

Throws

CCIPTransactionNotFoundError if transaction does not exist (transient)

Example

TypeScript
const chain = await EVMChain.fromUrl('https://eth-mainnet.example.com')
try {
const tx = await chain.getTransaction('0xabc123...')
console.log(`Block: ${tx.blockNumber}, Timestamp: ${tx.timestamp}`)
} catch (err) {
if (err instanceof CCIPTransactionNotFoundError && err.isTransient) {
// Transaction may be pending
}
}

sendMessage()

abstract sendMessage(opts: SendMessageOpts & { wallet: unknown; }): Promise<CCIPRequest<CCIPVersion>>

Defined in: chain.ts:866

Send a CCIP message through a router using provided wallet.

Parameters

ParameterTypeDescription
optsSendMessageOpts & { wallet: unknown; }SendMessageOpts with chain-specific wallet for signing

Returns

Promise<CCIPRequest<CCIPVersion>>

Promise resolving to CCIP request with message details

Throws

CCIPWalletNotSignerError if wallet is not a valid signer

Throws

CCIPLaneNotFoundError if no lane exists to destination

Example

TypeScript
const request = await chain.sendMessage({
router: '0x...',
destChainSelector: 4949039107694359620n,
message: {
receiver: '0x...',
data: '0x1337',
tokenAmounts: [{ token: '0x...', amount: 100n }],
feeToken: '0xLinkToken',
},
wallet: signer,
})
console.log(`Message ID: ${request.message.messageId}`)

typeAndVersion()

abstract typeAndVersion(address: string): Promise<[string, string, string, string]>

Defined in: chain.ts:628

Fetch typeAndVersion for a given CCIP contract address.

Parameters

ParameterTypeDescription
addressstringCCIP contract address

Returns

Promise<[string, string, string, string]>

Promise resolving to tuple:

  • type - Parsed type of the contract, e.g. OnRamp
  • version - Parsed version of the contract, e.g. 1.6.0
  • typeAndVersion - Original (unparsed) typeAndVersion() string
  • suffix - Suffix of the version, if any (e.g. -dev)

Throws

CCIPTypeVersionInvalidError if typeAndVersion string cannot be parsed

Example

TypeScript
const [type, version] = await chain.typeAndVersion(contractAddress)
console.log(`Contract: ${type} v${version}`)
if (version < '1.6.0') {
console.log('Legacy contract detected')
}

waitFinalized()

waitFinalized(opts: { cancel$?: Promise<unknown>; finality?: number | "finalized"; request: { log: { } & { } & { } & { } & { tx?: { timestamp: number; }; }; tx?: { timestamp: number; }; }; }): Promise<true>

Defined in: chain.ts:428

Confirm a log tx is finalized or wait for it to be finalized.

Parameters

ParameterTypeDescription
opts{ cancel$?: Promise<unknown>; finality?: number | "finalized"; request: { log: { } & { } & { } & { } & { tx?: { timestamp: number; }; }; tx?: { timestamp: number; }; }; }Options containing the request, finality level, and optional cancel promise
opts.cancel$?Promise<unknown>-
opts.finality?number | "finalized"-
opts.request{ log: { } & { } & { } & { } & { tx?: { timestamp: number; }; }; tx?: { timestamp: number; }; }-
opts.request.log{ } & { } & { } & { } & { tx?: { timestamp: number; }; }Log event from the OnRamp.
opts.request.tx?{ timestamp: number; }Transaction that emitted the request.
opts.request.tx.timestampnumberUnix timestamp of the block.

Returns

Promise<true>

true when the transaction is finalized

Throws

CCIPTransactionNotFinalizedError if the transaction is not included (e.g., due to a reorg)

Example

TypeScript
const request = await source.getMessagesInTx(txHash)
try {
await source.waitFinalized({ request: request[0] })
console.log('Transaction finalized')
} catch (err) {
if (err instanceof CCIPTransactionNotFinalizedError) {
console.log('Transaction not yet finalized')
}
}