Class: TONChain
Defined in: ton/index.ts:78
TON chain implementation supporting TON networks.
TON uses two different ordering concepts:
seqno(sequence number): The actual block number in the blockchainlt(logical time): A per-account transaction ordering timestamp
This implementation uses lt for the blockNumber field in logs and transactions
because TON's transaction APIs are indexed by lt, not seqno. The lt is
monotonically increasing per account and suitable for pagination and ordering.
Extends
Indexable
[key: symbol]: () => string
Constructors
Constructor
new TONChain(
client:TonClient,network:NetworkInfo,ctx?:WithLogger& {apiClient?:CCIPAPIClient|null;apiRetryConfig?:ApiRetryConfig; } & {fetchFn?: (input:string|URL|Request,init?:RequestInit) =>Promise<Response>; }):TONChain
Defined in: ton/index.ts:93
Creates a new TONChain instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
client | TonClient | TonClient instance. |
network | NetworkInfo | Network information for this chain. |
ctx? | WithLogger & { apiClient?: CCIPAPIClient | null; apiRetryConfig?: ApiRetryConfig; } & { fetchFn?: (input: string | URL | Request, init?: RequestInit) => Promise<Response>; } | Context containing logger. |
Returns
TONChain
Overrides
Chain<typeof ChainFamily.TON>.constructor
Properties
apiClient
readonlyapiClient:CCIPAPIClient|null
Defined in: chain.ts:339
CCIP API client (null if opted out)
Inherited from
apiRetryConfig
readonlyapiRetryConfig:Required<ApiRetryConfig> |null
Defined in: chain.ts:341
Retry configuration for API fallback operations (null if API client is disabled)
Inherited from
logger
logger:
Logger
Defined in: chain.ts:337
Inherited from
network
readonlynetwork:NetworkInfo<"TON">
Defined in: chain.ts:336
Inherited from
provider
readonlyprovider:TonClient
Defined in: ton/index.ts:85
rateLimitedFetch()
readonlyrateLimitedFetch: (input:string|URL|Request,init?:RequestInit) =>Promise<Response>
Defined in: ton/index.ts:84
Parameters
| Parameter | Type |
|---|---|
input | string | URL | Request |
init? | RequestInit |
Returns
Promise<Response>
decimals
readonlystaticdecimals:9=9
Defined in: ton/index.ts:83
family
readonlystaticfamily:"TON"=ChainFamily.TON
Defined in: ton/index.ts:82
Methods
destroy()?
optionaldestroy():void|Promise<void>
Defined in: chain.ts:375
Cleanup method to release resources (e.g., close connections).
Returns
void | Promise<void>
Inherited from
estimateReceiveExecution()?
optionalestimateReceiveExecution(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:1347
Estimate ccipReceive execution cost (gas, computeUnits) for this dest
Parameters
| Parameter | Type | Description |
|---|---|---|
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.messageId | string | - |
opts.message.sender? | string | - |
opts.message.sourceChainSelector | bigint | - |
opts.offRamp | string | - |
opts.receiver | string | - |
Returns
Promise<number>
estimated execution cost (gas or computeUnits)
Inherited from
Chain.estimateReceiveExecution
execute()
execute(
opts:ExecuteOpts& {wallet:unknown; }):Promise<CCIPExecution>
Defined in: ton/index.ts:1138
Execute messages in report in an offRamp.
Parameters
| Parameter | Type | Description |
|---|---|---|
opts | ExecuteOpts & { wallet: unknown; } | ExecuteOpts with chain-specific wallet to sign and send tx |
Returns
Promise<CCIPExecution>
Promise resolving to transaction of the execution
Throws
CCIPWalletInvalidError if wallet is not a valid TON wallet
Throws
CCIPReceiptNotFoundError if execution receipt not found within timeout
Overrides
generateUnsignedExecute()
generateUnsignedExecute(
opts:ExecuteOpts& {payer:string; }):Promise<UnsignedTONTx>
Defined in: ton/index.ts:1106
Generate unsigned tx to manuallyExecute a message.
Parameters
| Parameter | Type | Description |
|---|---|---|
opts | ExecuteOpts & { payer: string; } | ExecuteOpts with payer address which will send the exec tx |
Returns
Promise<UnsignedTONTx>
Promise resolving to chain-family specific unsigned txs
Throws
CCIPExtraArgsInvalidError if extra args are not EVMExtraArgsV2 format
Overrides
generateUnsignedSendMessage()
generateUnsignedSendMessage(
__namedParameters:SendMessageOpts& {sender:string; }):Promise<UnsignedTONTx>
Defined in: ton/index.ts:1013
Generate unsigned txs for ccipSend'ing a message.
Parameters
| Parameter | Type | Description |
|---|---|---|
__namedParameters | SendMessageOpts & { sender: string; } | SendMessageOpts with sender address |
Returns
Promise<UnsignedTONTx>
Promise resolving to chain-family specific unsigned txs
Overrides
Chain.generateUnsignedSendMessage
getBalance()
getBalance(
opts:GetBalanceOpts):Promise<bigint>
Defined in: ton/index.ts:540
Query token balance for an address.
Parameters
| Parameter | Type | Description |
|---|---|---|
opts | GetBalanceOpts | Balance query options |
Returns
Promise<bigint>
Token balance information including raw and formatted values
Throws
CCIPNotImplementedError always (not implemented for TON)
Overrides
getBlockTimestamp()
getBlockTimestamp(
block:number|"finalized"):Promise<number>
Defined in: ton/index.ts:229
Fetch the timestamp for a given logical time (lt) or finalized block.
Note: For TON, the block parameter represents logical time (lt), not block seqno.
This is because TON transaction APIs are indexed by lt. The lt must have been
previously cached via getLogs or getTransaction calls.
Parameters
| Parameter | Type | Description |
|---|---|---|
block | number | "finalized" | Logical time (lt) as number, or 'finalized' for latest block timestamp |
Returns
Promise<number>
Unix timestamp in seconds
Throws
CCIPNotImplementedError if lt is not in cache
Overrides
getExecutionInput()
getExecutionInput(
opts: {request:CCIPRequest;verifications:CCIPVerifications; } &Pick<LogFilter,"page">):Promise<ExecutionInput>
Defined in: chain.ts:629
Fetch input data needed for executing messages Should be called on the source instance
Parameters
| Parameter | Type | Description |
|---|---|---|
opts | { request: CCIPRequest; verifications: CCIPVerifications; } & Pick<LogFilter, "page"> | getExecutionInput options containing request and verifications |
Returns
Promise<ExecutionInput>
input payload to be passed to [[execute]]
See
execute - method to execute a message
Inherited from
getExecutionReceipts()
getExecutionReceipts(
opts: {messageId?:string;offRamp:string;sourceChainSelector?:bigint;verifications?:CCIPVerifications; } &Pick<LogFilter,"startBlock"|"startTime"|"watch"|"page">):AsyncIterableIterator<CCIPExecution>
Defined in: chain.ts:1072
Default/generic implementation of getExecutionReceipts. Yields execution receipts for a given offRamp.
Parameters
| Parameter | Type | Description |
|---|---|---|
opts | { messageId?: string; offRamp: string; sourceChainSelector?: bigint; verifications?: CCIPVerifications; } & Pick<LogFilter, "startBlock" | "startTime" | "watch" | "page"> | getExecutionReceipts options |
Returns
AsyncIterableIterator<CCIPExecution>
Async generator of CCIPExecution receipts
Example
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
}
Inherited from
getFee()
getFee(
__namedParameters:Omit<SendMessageOpts,"approveMax">):Promise<bigint>
Defined in: ton/index.ts:999
Fetch the current fee for a given intended message.
Parameters
| Parameter | Type | Description |
|---|---|---|
__namedParameters | Omit<SendMessageOpts, "approveMax"> | SendMessageOpts without approveMax |
Returns
Promise<bigint>
Fee amount in the feeToken's smallest units
Overrides
getFeeTokens()
getFeeTokens(
_router:string):Promise<never>
Defined in: ton/index.ts:1220
Fetch list and info of supported feeTokens.
Parameters
| Parameter | Type | Description |
|---|---|---|
_router | string | Router address on this chain |
Returns
Promise<never>
Promise resolving to mapping of token addresses to TokenInfo objects
Throws
CCIPNotImplementedError always (not implemented for TON)
Overrides
getLaneLatency()
getLaneLatency(
destChainSelector:bigint):Promise<LaneLatencyResponse>
Defined in: chain.ts:1046
Fetches estimated lane latency to a destination chain. Uses this chain's selector as the source.
Parameters
| Parameter | Type | Description |
|---|---|---|
destChainSelector | bigint | Destination CCIP chain selector (bigint) |
Returns
Promise<LaneLatencyResponse>
Promise resolving to LaneLatencyResponse containing:
lane.sourceNetworkInfo- Source chain metadata (name, selector, chainId)lane.destNetworkInfo- Destination chain metadatalane.routerAddress- Router contract address on source chaintotalMs- 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
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}`)
}
}
Inherited from
getLogs()
Defined in: ton/index.ts:353
Async generator that yields logs from TON transactions.
Note: For TON, startBlock and endBlock in opts represent logical time (lt),
not block sequence numbers. This is because TON transaction APIs are indexed by lt.
Parameters
| Parameter | Type | Description |
|---|---|---|
opts | LogFilter | Log filter options (startBlock/endBlock are interpreted as lt values) |
Returns
AsyncIterableIterator<ChainLog>
Throws
CCIPTopicsInvalidError if topics format is invalid
Overrides
getMessageById()
getMessageById(
messageId:string,_opts?: {onRamp?:string;page?:number; }):Promise<CCIPRequest<CCIPVersion>>
Defined in: chain.ts:581
Fetch a CCIP message by its unique message ID.
Parameters
| Parameter | Type | Description |
|---|---|---|
messageId | string | The 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
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
Inherited from
getMessagesInBatch()
getMessagesInBatch<
R>(request:R,range:Pick<CommitReport,"minSeqNr"|"maxSeqNr">,opts?:Pick<LogFilter,"page">):Promise<R["message"][]>
Defined in: ton/index.ts:375
Fetches all CCIP messages contained in a given commit batch. To be implemented for chains supporting CCIPVersion <= v1.6.0
Type Parameters
| Type Parameter | Description |
|---|---|
R extends { lane: Lane<CCIPVersion>; log: { } & { } & { }; message: { sequenceNumber: bigint; } | { sequenceNumber: bigint; } | { sequenceNumber: bigint; } | { sequenceNumber: bigint; } | { sequenceNumber: bigint; } | { sequenceNumber: bigint; }; } |
Parameters
| Parameter | Type | Description |
|---|---|---|
request | R | CCIPRequest to fetch batch for |
range | Pick<CommitReport, "minSeqNr" | "maxSeqNr"> | batch range { minSeqnr, maxSeqNr }, e.g. from [[CommitReport]] |
opts? | Pick<LogFilter, "page"> | Optional parameters (e.g., page for pagination width) |
Returns
Promise<R["message"][]>
Array of messages in the batch
Overrides
getMessagesInTx()
getMessagesInTx(
tx:string|ChainTransaction):Promise<CCIPRequest<CCIPVersion>[]>
Defined in: chain.ts:525
Fetch all CCIP requests in a transaction.
Parameters
| Parameter | Type | Description |
|---|---|---|
tx | string | ChainTransaction | ChainTransaction 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
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}`)
}
Inherited from
getNativeTokenForRouter()
getNativeTokenForRouter(
_router:string):Promise<string>
Defined in: ton/index.ts:436
Get the native token address for a Router.
Parameters
| Parameter | Type | Description |
|---|---|---|
_router | string | Router contract address |
Returns
Promise<string>
Promise resolving to native token address (usually wrapped)
Throws
CCIPNotImplementedError always (not implemented for TON)
Overrides
getOffchainTokenData()
getOffchainTokenData(
request: {message: {ccipReceiveGasLimit:number;ccvAndExecutorHash:string;data:string;destBlob:string;destChainSelector:bigint;encodedMessage:string;executionGasLimit:number;feeToken:string;feeTokenAmount:bigint;finality:number;messageId:string;messageNumber:bigint;offRampAddress:string;onRampAddress:string;receipts: readonly {destBytesOverhead:bigint;destGasLimit:bigint;extraArgs:string;feeTokenAmount:bigint;issuer:string; }[];receiver:string;sender:string;sequenceNumber:bigint;sourceChainSelector:bigint;tokenAmountBeforeTokenPoolFees:bigint;tokenAmounts: readonlyTokenTransferV1[];verifierBlobs: readonlystring[]; } | {data:string;feeToken:string;feeTokenAmount:bigint;gasLimit:bigint;messageId:string;nonce:bigint;receiver:string;sender:string;sequenceNumber:bigint;sourceChainSelector:bigint;sourceTokenData: readonlystring[];strict:boolean;tokenAmounts: readonly {amount:bigint;token:string; }[]; } |CCIPMessage_V1_5_EVM|CCIPMessage_V1_6_EVM|CCIPMessage_V1_6_Solana|CCIPMessage_V1_6_Sui;tx: {hash:string; }; }):Promise<OffchainTokenData[]>
Defined in: chain.ts:926
Fetch supported offchain token data for a request from this network. It logs but doesn't throw in case it can't fetch attestation, as the transfers may not be from the expected attestation providers. It returns default offchainData=undefined for those.
Parameters
| Parameter | Type | Description |
|---|---|---|
request | { message: { ccipReceiveGasLimit: number; ccvAndExecutorHash: string; data: string; destBlob: string; destChainSelector: bigint; encodedMessage: string; executionGasLimit: number; feeToken: string; feeTokenAmount: bigint; finality: number; messageId: string; messageNumber: bigint; offRampAddress: string; onRampAddress: string; receipts: readonly { destBytesOverhead: bigint; destGasLimit: bigint; extraArgs: string; feeTokenAmount: bigint; issuer: string; }[]; receiver: string; sender: string; sequenceNumber: bigint; sourceChainSelector: bigint; tokenAmountBeforeTokenPoolFees: bigint; tokenAmounts: readonly TokenTransferV1[]; verifierBlobs: readonly string[]; } | { data: string; feeToken: string; feeTokenAmount: bigint; gasLimit: bigint; messageId: string; nonce: bigint; receiver: string; sender: string; sequenceNumber: bigint; sourceChainSelector: bigint; sourceTokenData: readonly string[]; strict: boolean; tokenAmounts: readonly { amount: bigint; token: string; }[]; } | CCIPMessage_V1_5_EVM | CCIPMessage_V1_6_EVM | CCIPMessage_V1_6_Solana | CCIPMessage_V1_6_Sui; tx: { hash: string; }; } | CCIP request, with tx.hash and message |
request.message | { ccipReceiveGasLimit: number; ccvAndExecutorHash: string; data: string; destBlob: string; destChainSelector: bigint; encodedMessage: string; executionGasLimit: number; feeToken: string; feeTokenAmount: bigint; finality: number; messageId: string; messageNumber: bigint; offRampAddress: string; onRampAddress: string; receipts: readonly { destBytesOverhead: bigint; destGasLimit: bigint; extraArgs: string; feeTokenAmount: bigint; issuer: string; }[]; receiver: string; sender: string; sequenceNumber: bigint; sourceChainSelector: bigint; tokenAmountBeforeTokenPoolFees: bigint; tokenAmounts: readonly TokenTransferV1[]; verifierBlobs: readonly string[]; } | { data: string; feeToken: string; feeTokenAmount: bigint; gasLimit: bigint; messageId: string; nonce: bigint; receiver: string; sender: string; sequenceNumber: bigint; sourceChainSelector: bigint; sourceTokenData: readonly string[]; strict: boolean; tokenAmounts: readonly { amount: bigint; token: string; }[]; } | CCIPMessage_V1_5_EVM | CCIPMessage_V1_6_EVM | CCIPMessage_V1_6_Solana | CCIPMessage_V1_6_Sui | - |
request.tx | { hash: string; } | Transaction that emitted the request. |
request.tx.hash | string | Transaction hash. |
Returns
Promise<OffchainTokenData[]>
Promise resolving to array with one offchain token data for each token transfer
Example
const offchainData = await source.getOffchainTokenData(request)
// Use in execution report
Inherited from
getOffRampsForRouter()
getOffRampsForRouter(
router:string,sourceChainSelector:bigint):Promise<string[]>
Defined in: ton/index.ts:443
Fetch the OffRamps allowlisted in a Router. Used to discover OffRamp connected to an OnRamp.
Parameters
| Parameter | Type | Description |
|---|---|---|
router | string | Router contract address |
sourceChainSelector | bigint | Source chain selector |
Returns
Promise<string[]>
Promise resolving to array of OffRamp addresses
Overrides
getOnRampForRouter()
getOnRampForRouter(
router:string,destChainSelector:bigint):Promise<string>
Defined in: ton/index.ts:453
Fetch the OnRamp registered in a Router for a destination chain.
Parameters
| Parameter | Type | Description |
|---|---|---|
router | string | Router contract address |
destChainSelector | bigint | Destination chain selector |
Returns
Promise<string>
Promise resolving to OnRamp address
Overrides
getOnRampsForOffRamp()
getOnRampsForOffRamp(
offRamp:string,sourceChainSelector:bigint):Promise<string[]>
Defined in: ton/index.ts:466
Fetch the OnRamps addresses set in OffRamp config. Used to discover OffRamp connected to an OnRamp.
Parameters
| Parameter | Type | Description |
|---|---|---|
offRamp | string | OffRamp contract address |
sourceChainSelector | bigint | Source chain selector |
Returns
Promise<string[]>
Promise resolving to OnRamps addresses
Throws
CCIPSourceChainUnsupportedError if source chain is not configured
Overrides
getRegistryTokenConfig()
getRegistryTokenConfig(
_address:string,_tokenName:string):Promise<never>
Defined in: ton/index.ts:1196
Fetch token configuration from a TokenAdminRegistry.
Parameters
| Parameter | Type | Description |
|---|---|---|
_address | string | TokenAdminRegistry contract address. |
_tokenName | string | Token address to query. |
Returns
Promise<never>
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.
Throws
CCIPNotImplementedError always (not implemented for TON)
Overrides
getRouterForOffRamp()
getRouterForOffRamp(
offRamp:string,sourceChainSelector:bigint):Promise<string>
Defined in: ton/index.ts:425
Fetch the Router address set in OffRamp config.
Parameters
| Parameter | Type | Description |
|---|---|---|
offRamp | string | OffRamp contract address |
sourceChainSelector | bigint | Source chain selector |
Returns
Promise<string>
Promise resolving to Router address
Overrides
getRouterForOnRamp()
getRouterForOnRamp(
onRamp:string,destChainSelector:bigint):Promise<string>
Defined in: ton/index.ts:415
Fetch the Router address set in OnRamp config. Used to discover OffRamp connected to OnRamp.
Parameters
| Parameter | Type | Description |
|---|---|---|
onRamp | string | OnRamp contract address |
destChainSelector | bigint | Destination chain selector |
Returns
Promise<string>
Promise resolving to Router address
Overrides
getSupportedTokens()
getSupportedTokens(
_address:string):Promise<string[]>
Defined in: ton/index.ts:1188
List tokens supported by given TokenAdminRegistry contract.
Parameters
| Parameter | Type | Description |
|---|---|---|
_address | string | Usually TokenAdminRegistry, but chain may support receiving Router, OnRamp, etc. |
Returns
Promise<string[]>
Promise resolving to array of supported token addresses
Throws
CCIPNotImplementedError always (not implemented for TON)
Overrides
getTokenAdminRegistryFor()
getTokenAdminRegistryFor(
_address:string):Promise<string>
Defined in: ton/index.ts:575
Fetch TokenAdminRegistry configured in a given OnRamp, Router, etc. Needed to map a source token to its dest counterparts.
Parameters
| Parameter | Type | Description |
|---|---|---|
_address | string | Contract address (OnRamp, Router, etc.) |
Returns
Promise<string>
Promise resolving to TokenAdminRegistry address
Throws
CCIPNotImplementedError always (not implemented for TON)
Overrides
Chain.getTokenAdminRegistryFor
getTokenForTokenPool()
getTokenForTokenPool(
_tokenPool:string):Promise<string>
Defined in: ton/index.ts:509
Fetch the TokenPool's token/mint.
Parameters
| Parameter | Type | Description |
|---|---|---|
_tokenPool | string | TokenPool address |
Returns
Promise<string>
Promise resolving to token or mint address
Throws
CCIPNotImplementedError always (not implemented for TON)
Overrides
getTokenInfo()
getTokenInfo(
token:string):Promise<{decimals:number;symbol:string; }>
Defined in: ton/index.ts:514
Fetch token metadata.
Parameters
| Parameter | Type | Description |
|---|---|---|
token | string | Token address |
Returns
Promise<{ decimals: number; symbol: string; }>
Promise resolving to token symbol, decimals, and optionally name
Overrides
getTokenPoolConfig()
getTokenPoolConfig(
_tokenPool:string):Promise<never>
Defined in: ton/index.ts:1204
Fetch configuration of a token pool.
Parameters
| Parameter | Type | Description |
|---|---|---|
_tokenPool | string | Token pool contract address. |
Returns
Promise<never>
TokenPoolConfig containing token, router, and version info.
Remarks
Return type varies by chain:
- EVM:
typeAndVersionis always present (required) - Solana: Includes extra
tokenPoolProgramfield - Aptos: Standard fields only
- Sui/TON: Throws CCIPNotImplementedError
Throws
CCIPNotImplementedError always (not implemented for TON)
Overrides
getTokenPoolRemote()
getTokenPoolRemote(
tokenPool:string,remoteChainSelector:bigint):Promise<TokenPoolRemote>
Defined in: chain.ts:1271
Fetch remote chain configuration for a token pool for a specific destination.
Parameters
| Parameter | Type | Description |
|---|---|---|
tokenPool | string | Token pool address on the current chain. |
remoteChainSelector | bigint | Chain 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
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.
Inherited from
getTokenPoolRemotes()
getTokenPoolRemotes(
_tokenPool:string):Promise<never>
Defined in: ton/index.ts:1212
Fetch remote chain configurations for a token pool.
Parameters
| Parameter | Type | Description |
|---|---|---|
_tokenPool | string | Token pool address on the current chain. |
Returns
Promise<never>
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.
Throws
CCIPNotImplementedError always (not implemented for TON)
Overrides
getTransaction()
getTransaction(
tx:string|Transaction):Promise<ChainTransaction>
Defined in: ton/index.ts:258
Fetches a transaction by its hash.
Supports two formats:
- Composite format: "workchain:address:lt:hash" (e.g., "0:abc123...def:12345:abc123...def")
- Raw hash format: 64-character hex string resolved via TonCenter V3 API
Note: TonClient requires (address, lt, hash) for lookups. Raw hash lookups use TonCenter's V3 index API to resolve the hash to a full identifier first.
Parameters
| Parameter | Type | Description |
|---|---|---|
tx | string | Transaction | Transaction identifier in either format |
Returns
Promise<ChainTransaction>
ChainTransaction with transaction details
Note: blockNumber contains logical time (lt), not block seqno
Throws
CCIPArgumentInvalidError if hash format is invalid
Throws
CCIPTransactionNotFoundError if transaction not found
Overrides
getVerifications()
getVerifications(
opts: {offRamp:string;request: {lane:Lane<CCIPVersion>;message: {sequenceNumber:bigint; } | {sequenceNumber:bigint; } | {sequenceNumber:bigint; } | {sequenceNumber:bigint; } | {sequenceNumber:bigint; } | {sequenceNumber:bigint; } & {messageId:string; } | {messageId:string; } | {messageId:string; } | {messageId:string; } | {messageId:string; } | {messageId:string; };tx: {timestamp:number; }; }; } &Pick<LogFilter,"startBlock"|"watch"|"page">):Promise<CCIPVerifications>
Defined in: chain.ts:998
Look for a CommitReport at dest for given CCIP request. May be specialized by some subclasses.
Parameters
| Parameter | Type | Description |
|---|---|---|
opts | { offRamp: string; request: { lane: Lane<CCIPVersion>; message: { sequenceNumber: bigint; } | { sequenceNumber: bigint; } | { sequenceNumber: bigint; } | { sequenceNumber: bigint; } | { sequenceNumber: bigint; } | { sequenceNumber: bigint; } & { messageId: string; } | { messageId: string; } | { messageId: string; } | { messageId: string; } | { messageId: string; } | { messageId: string; }; tx: { timestamp: number; }; }; } & Pick<LogFilter, "startBlock" | "watch" | "page"> | getVerifications options |
Returns
Promise<CCIPVerifications>
CCIPVerifications
Throws
CCIPCommitNotFoundError if no commit found for the request (transient)
Example
const verifications = await dest.getVerifications({
offRamp: offRampAddress,
request,
})
console.log(`Committed at block: ${verifications.log.blockNumber}`)
Inherited from
sendMessage()
sendMessage(
__namedParameters:SendMessageOpts& {wallet:unknown; }):Promise<CCIPRequest<CCIPVersion>>
Defined in: ton/index.ts:1043
Send a CCIP message through a router using provided wallet.
Parameters
| Parameter | Type | Description |
|---|---|---|
__namedParameters | SendMessageOpts & { wallet: unknown; } | SendMessageOpts with chain-specific wallet for signing |
Returns
Promise<CCIPRequest<CCIPVersion>>
Promise resolving to CCIP request with message details
Overrides
typeAndVersion()
typeAndVersion(
address:string):Promise<[string,string,string,string]>
Defined in: ton/index.ts:389
Fetch typeAndVersion for a given CCIP contract address.
Parameters
| Parameter | Type | Description |
|---|---|---|
address | string | CCIP contract address |
Returns
Promise<[string, string, string, string]>
Promise resolving to tuple:
type- Parsed type of the contract, e.g.OnRampversion- Parsed version of the contract, e.g.1.6.0typeAndVersion- Original (unparsed) typeAndVersion() stringsuffix- Suffix of the version, if any (e.g.-dev)
Overrides
waitFinalized()
waitFinalized(
opts: {cancel$?:Promise<unknown>;finality?:number|"finalized";request: {log: { } & { } & { } & { } & {tx?: {timestamp:number; }; };tx?: {timestamp:number; }; }; }):Promise<true>
Defined in: chain.ts:441
Confirm a log tx is finalized or wait for it to be finalized.
Parameters
| Parameter | Type | Description |
|---|---|---|
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; }; } | - |
opts.request.tx? | { timestamp: number; } | Transaction that emitted the request. |
opts.request.tx.timestamp | number | Unix 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
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')
}
}
Inherited from
buildMessageForDest()
staticbuildMessageForDest(message:MessageInput):AnyMessage
Defined in: chain.ts:1307
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
Inherited from
Chain.buildMessageForDest
decodeCommits()
staticdecodeCommits(log: {data:unknown;topics?: readonlystring[]; },lane?:Lane<CCIPVersion>): {maxSeqNr:bigint;merkleRoot:string;minSeqNr:bigint;onRampAddress:string;sourceChainSelector:bigint; }[] |undefined
Defined in: ton/index.ts:757
Decodes commit reports from a TON log event (CommitReportAccepted).
Parameters
| Parameter | Type | Description |
|---|---|---|
log | { data: unknown; topics?: readonly string[]; } | Log with data field (base64-encoded BOC). |
log.data | unknown | - |
log.topics? | readonly string[] | - |
lane? | Lane<CCIPVersion> | Optional lane info for filtering. |
Returns
{ maxSeqNr: bigint; merkleRoot: string; minSeqNr: bigint; onRampAddress: string; sourceChainSelector: bigint; }[] | undefined
Array of CommitReport or undefined if not a valid commit event.
decodeExtraArgs()
staticdecodeExtraArgs(extraArgs:BytesLike):EVMExtraArgsV1& {allowOutOfOrderExecution:boolean; } & {_tag:"EVMExtraArgsV2"; } |undefined
Defined in: ton/index.ts:725
Decodes BOC-encoded extra arguments from TON messages. Parses the BOC format and extracts extra args, validating the magic tag to ensure correct type. Returns undefined if parsing fails or tag doesn't match.
Currently only supports EVMExtraArgsV2 (GenericExtraArgsV2) encoding since TON lanes are only connected to EVM chains. When new lanes are planned to be added, this should be extended to support them (eg. Solana and SVMExtraArgsV1)
Parameters
| Parameter | Type | Description |
|---|---|---|
extraArgs | BytesLike | BOC-encoded extra args as hex string or bytes |
Returns
EVMExtraArgsV1 & { allowOutOfOrderExecution: boolean; } & { _tag: "EVMExtraArgsV2"; }
undefined
Decoded EVMExtraArgsV2 (GenericExtraArgsV2) object or undefined if invalid
decodeMessage()
staticdecodeMessage(log: {data:unknown;topics?: readonlystring[]; }):CCIPMessage_V1_6_EVM|undefined
Defined in: ton/index.ts:584
Decodes a CCIP message from a TON log event.
Parameters
| Parameter | Type | Description |
|---|---|---|
log | { data: unknown; topics?: readonly string[]; } | Log with data field. |
log.data | unknown | - |
log.topics? | readonly string[] | - |
Returns
CCIPMessage_V1_6_EVM | undefined
Decoded CCIPMessage or undefined if not valid.
decodeReceipt()
staticdecodeReceipt(log: {data:unknown;topics?: readonlystring[]; }):ExecutionReceipt|undefined
Defined in: ton/index.ts:829
Decodes an execution receipt from a TON log event.
The ExecutionStateChanged event structure (topic is in message header, not body):
- sourceChainSelector: uint64 (8 bytes)
- sequenceNumber: uint64 (8 bytes)
- messageId: uint256 (32 bytes)
- state: uint8 (1 byte) - InProgress=1, Success=2, Failed=3
Parameters
| Parameter | Type | Description |
|---|---|---|
log | { data: unknown; topics?: readonly string[]; } | Log with data field (base64-encoded BOC). |
log.data | unknown | - |
log.topics? | readonly string[] | - |
Returns
ExecutionReceipt | undefined
ExecutionReceipt or undefined if not valid.
encodeExtraArgs()
staticencodeExtraArgs(args:ExtraArgs):string
Defined in: ton/index.ts:699
Encodes extra args from TON messages into BOC serialization format.
Currently only supports GenericExtraArgsV2 (EVMExtraArgsV2) encoding since TON lanes are only connected to EVM chains. When new lanes are planned to be added, this should be extended to support them (eg. Solana and SVMExtraArgsV1)
Parameters
| Parameter | Type | Description |
|---|---|---|
args | ExtraArgs | Extra arguments containing gas limit and execution flags |
Returns
string
Hex string of BOC-encoded extra args (0x-prefixed)
formatAddress()
staticformatAddress(address:string):string
Defined in: ton/index.ts:928
Formats a TON address for human-friendly display. Converts raw format (workchain:hash) to user-friendly format (EQ..., UQ..., etc.)
Parameters
| Parameter | Type | Description |
|---|---|---|
address | string | Address in any recognized format |
Returns
string
User-friendly TON address string
formatTxHash()
staticformatTxHash(hash:string):string
Defined in: ton/index.ts:946
Formats a TON transaction hash for human-friendly display. Extracts the raw 64-char hash from composite format for cleaner display.
Parameters
| Parameter | Type | Description |
|---|---|---|
hash | string | Transaction hash in composite or raw format |
Returns
string
The raw 64-char hex hash for display
fromClient()
staticfromClient(client:TonClient,ctx?:WithLogger& {apiClient?:CCIPAPIClient|null;apiRetryConfig?:ApiRetryConfig; } & {fetchFn?: (input:string|URL|Request,init?:RequestInit) =>Promise<Response>; }):Promise<TONChain>
Defined in: ton/index.ts:165
Detect client network and instantiate a TONChain instance.
Parameters
| Parameter | Type |
|---|---|
client | TonClient |
ctx? | WithLogger & { apiClient?: CCIPAPIClient | null; apiRetryConfig?: ApiRetryConfig; } & { fetchFn?: (input: string | URL | Request, init?: RequestInit) => Promise<Response>; } |
Returns
Promise<TONChain>
fromUrl()
staticfromUrl(url:string,ctx?:ChainContext):Promise<TONChain>
Defined in: ton/index.ts:188
Creates a TONChain instance from an RPC URL. Verifies the connection and detects the network.
Parameters
| Parameter | Type | Description |
|---|---|---|
url | string | RPC endpoint URL for TonClient (v2). |
ctx? | ChainContext | Context containing logger. |
Returns
Promise<TONChain>
A new TONChain instance.
Throws
CCIPHttpError if connection to the RPC endpoint fails
getAddress()
staticgetAddress(bytes:BytesLike):string
Defined in: ton/index.ts:881
Converts bytes to a TON address. Handles:
- 36-byte CCIP format: workchain(4 bytes, big-endian) + hash(32 bytes)
- 33-byte format: workchain(1 byte) + hash(32 bytes)
- 32-byte format: hash only (assumes workchain 0) Also handles user-friendly format strings (e.g., "EQ...", "UQ...", "kQ...", "0Q...") and raw format strings ("workchain:hash").
Parameters
| Parameter | Type | Description |
|---|---|---|
bytes | BytesLike | Bytes or string to convert. |
Returns
string
TON raw address string in format "workchain:hash".
Throws
CCIPArgumentInvalidError if bytes length is invalid
getDestLeafHasher()
staticgetDestLeafHasher(lane:Lane,_ctx?:WithLogger):LeafHasher
Defined in: ton/index.ts:994
Gets the leaf hasher for TON destination chains.
Parameters
| Parameter | Type | Description |
|---|---|---|
lane | Lane | Lane configuration. |
_ctx? | WithLogger | Context containing logger. |
Returns
LeafHasher
Leaf hasher function.
isTxHash()
staticisTxHash(v:unknown):v is string
Defined in: ton/index.ts:962
Validates a transaction hash format for TON. Supports:
- Raw 64-char hex hash (with or without 0x prefix)
- Composite format: "workchain:address:lt:hash"
Parameters
| Parameter | Type |
|---|---|
v | unknown |
Returns
v is string
parse()
staticparse(data:unknown):EVMExtraArgsV1& {allowOutOfOrderExecution:boolean; } & {_tag:"EVMExtraArgsV2"; } |undefined
Defined in: ton/index.ts:1177
Parses raw TON data into typed structures.
Parameters
| Parameter | Type | Description |
|---|---|---|
data | unknown | Raw data to parse. |
Returns
EVMExtraArgsV1 & { allowOutOfOrderExecution: boolean; } & { _tag: "EVMExtraArgsV2"; }
undefined
Parsed data or undefined.