Skip to content
✈️ TokenFlight SDK

Token Pre-selection

You can pre-select the source token (fromToken), destination token (toToken), or both, so users land on a ready-to-go swap screen.

Three formats are accepted anywhere a TokenIdentifier is expected:

config: {
fromToken: { chainId: 1, address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48' },
toToken: { chainId: 8453, address: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913' },
}

CAIP-10 String (HTML attributes & imperative)

Section titled “CAIP-10 String (HTML attributes & imperative)”
eip155:<chainReference>:<tokenAddress>
<tokenflight-swap
from-token="eip155:1:0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
to-token="eip155:8453:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
></tokenflight-swap>
<tokenflight-swap
from-token='{"chainId":1,"address":"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"}'
></tokenflight-swap>
CAIP-10 PrefixChain
eip155:1Ethereum
eip155:137Polygon
eip155:42161Arbitrum One
eip155:8453Base
eip155:10Optimism
eip155:56BNB Chain
eip155:43114Avalanche C-Chain
solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpSolana

Any EVM eip155:<chainId> reference is accepted — the table above lists chains with built-in shortcuts.

const swap = new TokenFlightSwap({
container: '#swap',
config: {
theme: 'dark',
fromToken: { chainId: 1, address: '0x0000000000000000000000000000000000000000' },
toToken: { chainId: 8453, address: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913' },
},
});
swap.initialize();
const receive = new TokenFlightReceive({
container: '#receive',
config: {
target: { chainId: 8453, address: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913' },
amount: '50',
fromToken: 'eip155:1:0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
theme: 'dark',
},
});
receive.initialize();
<tokenflight-swap
theme="dark"
from-token="eip155:1:0x0000000000000000000000000000000000000000"
to-token="eip155:8453:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
default-slippage="50"
></tokenflight-swap>

Use the zero address to refer to a chain’s native token:

ChainNative Address
EVM0x0000000000000000000000000000000000000000
Solana11111111111111111111111111111111