Skip to main content
Version: 1.2.0

Function: sourceToDestTokenAddresses()

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

Defined in: requests.ts:479

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,
destChainSelector,
'0xOnRamp...',
{ token: '0xLINK...', amount: 1000000000000000000n }
)
console.log(`Pool: ${tokenAmount.sourcePoolAddress}`)
console.log(`Dest token: ${tokenAmount.destTokenAddress}`)