Skip to main content
Version: 1.14.0

Function: sourceToDestTokenAddresses()

sourceToDestTokenAddresses<S extends { token: string; }>(opts: { destChainSelector: bigint; onRamp: string; source: Chain; sourceTokenAmount: S; }): Promise<S & { destTokenAddress: string; sourcePoolAddress: string; sourceTokenAddress: string; }>

Defined in: gas.ts:139

Map source token to its pool address and destination token address.

Resolves token routing by querying the TokenAdminRegistry and TokenPool to find the corresponding destination chain token.

Type Parameters​

Type Parameter
S extends { token: string; }

Parameters​

ParameterTypeDescription
opts{ destChainSelector: bigint; onRamp: string; source: Chain; sourceTokenAmount: S; }options to convert source to dest token addresses
opts.destChainSelectorbigintDestination chain selector
opts.onRampstringOnRamp contract address
opts.sourceChainSource chain instance
opts.sourceTokenAmountSToken amount object containing token and amount

Returns​

Promise<S & { destTokenAddress: string; sourcePoolAddress: string; sourceTokenAddress: string; }>

Extended token amount with sourcePoolAddress, sourceTokenAddress, and destTokenAddress

Throws​

CCIPTokenNotInRegistryError if token is not registered in TokenAdminRegistry

Example​

TypeScript
import { sourceToDestTokenAddresses, EVMChain } from '@chainlink/ccip-sdk'

const source = await EVMChain.fromUrl('https://rpc.sepolia.org')
const tokenAmount = await sourceToDestTokenAddresses({
source,
onRamp: '0xOnRamp...',
destChainSelector: 14767482510784806043n,
sourceTokenAmount: { token: '0xLINK...', amount: 1000000000000000000n },
})
console.log(`Pool: ${tokenAmount.sourcePoolAddress}`)
console.log(`Dest token: ${tokenAmount.destTokenAddress}`)