@chainlink/ccip-sdk
v0.96.0
Published
SDK/Library to interact with CCIP
Maintainers
Keywords
Readme
@chainlink/ccip-sdk
TypeScript SDK for integrating CCIP (Cross-Chain Interoperability Protocol) into your applications.
[!IMPORTANT] This tool is provided under an MIT license and is for convenience and illustration purposes only.
📖 Full SDK Documentation - Complete API reference, advanced patterns, and tree-shaking guide.
Installation
npm install @chainlink/ccip-sdk[!NOTE] Node.js v20+ required. v23+ recommended for native TypeScript execution.
Chain Classes
The SDK provides a unified Chain class interface for each blockchain family. Create instances using fromUrl:
import { EVMChain, SolanaChain, AptosChain } from '@chainlink/ccip-sdk'
// EVM chains (Ethereum, Arbitrum, Optimism, etc.)
const evmChain = await EVMChain.fromUrl('https://ethereum-sepolia-rpc.publicnode.com')
// Solana
const solanaChain = await SolanaChain.fromUrl('https://api.devnet.solana.com')
// Aptos
const aptosChain = await AptosChain.fromUrl('https://api.testnet.aptoslabs.com/v1')Common Tasks
Track a CCIP Message
import { EVMChain } from '@chainlink/ccip-sdk'
const source = await EVMChain.fromUrl('https://ethereum-sepolia-rpc.publicnode.com')
// Fetch message details from a transaction
const requests = await source.getMessagesInTx(
'0xb8b27d9811509e3c364c9afaf8f14d8ebc65dec06327493981d7f7f4a00f2918'
)
const request = requests[0]
console.log('Message ID:', request.message.messageId)
console.log('Sender:', request.message.sender)
console.log('Destination chain:', request.lane.destChainSelector)Get Fee Estimate
import { EVMChain, networkInfo } from '@chainlink/ccip-sdk'
const source = await EVMChain.fromUrl('https://ethereum-sepolia-rpc.publicnode.com')
const router = '0x0BF3dE8c5D3e8A2B34D2BEeB17ABfCeBaf363A59' // Sepolia Router
const destChainSelector = networkInfo('ethereum-testnet-sepolia-arbitrum-1').chainSelector
const fee = await source.getFee({ router, destChainSelector, message: {
receiver: '0xYourReceiverAddress',
data: '0x48656c6c6f', // "Hello" in hex
extraArgs: { gasLimit: 200_000 }, // Gas limit for receiver's ccipReceive callback
} })
console.log('Fee in native token:', fee.toString())Send a Cross-Chain Message
import { EVMChain, networkInfo } from '@chainlink/ccip-sdk'
import { Wallet } from 'ethers'
const source = await EVMChain.fromUrl('https://ethereum-sepolia-rpc.publicnode.com')
const wallet = new Wallet('YOUR_PRIVATE_KEY', source.provider)
const router = '0x0BF3dE8c5D3e8A2B34D2BEeB17ABfCeBaf363A59'
const destChainSelector = networkInfo('ethereum-testnet-sepolia-arbitrum-1').chainSelector
// Get fee first
const fee = await source.getFee({ router, destChainSelector, message: {
receiver: '0xYourReceiverAddress',
data: '0x48656c6c6f',
extraArgs: {
gasLimit: 200_000,
allowOutOfOrderExecution: true, // Don't wait for prior messages from this sender
},
})
// Send the message
const request = await source.sendMessage({
router,
destChainSelector,
message: {
receiver: '0xYourReceiverAddress',
data: '0x48656c6c6f',
extraArgs: { gasLimit: 200_000, allowOutOfOrderExecution: true },
fee,
},
wallet,
})
console.log('Transaction hash:', request.tx.hash)
console.log('Message ID:', request.message.messageId)Wallet Configuration
Transaction-sending methods require a chain-specific wallet:
| Chain | Wallet Type | Example |
| ------ | --------------- | ------------------------------------------ |
| EVM | ethers.Signer | new Wallet(privateKey, provider) |
| Solana | anchor.Wallet | new Wallet(Keypair.fromSecretKey(...)) |
| Aptos | aptos.Account | Account.fromPrivateKey(...) |
Unsigned Transactions
For custom signing workflows (e.g., browser wallets, hardware wallets), use the generateUnsigned* methods:
// Generate unsigned transaction data
const unsignedTx = await source.generateUnsignedSendMessage({
sender, // Your wallet address
router,
destChainSelector,
message
})
// Sign and send with your own logic
for (const tx of unsignedTx.transactions) {
const signed = await customSigner.sign(tx)
await customSender.broadcast(signed)
}For EVM chains in browsers, get a signer from the connected wallet:
const signer = await source.provider.getSigner(0)Supported Chains
| Chain Family | Class | Library | Status |
| ------------ | ------------- | ------------------------------------------------------------------------ | -------------- |
| EVM | EVMChain | ethers.js v6 | Supported |
| Solana | SolanaChain | solana-web3.js | Supported |
| Aptos | AptosChain | aptos-ts-sdk | Supported |
| Sui | SuiChain | @mysten/sui | Partial (manual exec) |
| TON | TONChain | @ton/ton | Partial (manual exec) |
Related
- @chainlink/ccip-cli - Command-line interface
- CCIP Official Docs - Protocol documentation
- CCIP Directory - Router addresses
License
MIT
