@chainlink/ccip-sdk

中文文档
1.16.1发布于 2026/10/18MITTypeScriptES Module构建来源已验证近 30 天下载 1.8万

SDK/Library to interact with CCIP

原始使用文档
文档目录11 节
  1. Installation
  2. Chain Classes
  3. Common Tasks
  4. Track a CCIP Message
  5. Get Fee Estimate
  6. Send a Cross-Chain Message
  7. Wallet Configuration
  8. Unsigned Transactions
  9. Supported Chains
  10. Related
  11. License

@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. v24+ recommended for development (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, CantonChain } 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')

// Canton (requires CantonConfig — see Multi-Chain guide)
const cantonChain = await CantonChain.fromUrl('https://ledger.example.com/api/json', {
  cantonConfig: {
    party: 'sender::1220...',
    ccipParty: 'ccip::1220...',
    jwt: 'eyJ...',
    edsUrl: 'https://eds.example.com',
    transferInstructionUrl: 'https://transfer-instruction.example.com',
  },
})

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_000n }, // 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_000n,
    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_000n, 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:

ChainWallet TypeExample
EVMethers.Signernew Wallet(privateKey, provider)
Solanaanchor.Walletnew Wallet(Keypair.fromSecretKey(...))
Aptosaptos.AccountAccount.fromPrivateKey(...)
CantonCantonWalletParty ID from config + optional Ed25519 external signer

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 (EVM example - uses .transactions)
// Solana uses .instructions, Aptos uses .transactions (BCS-encoded), TON uses .body
// Canton uses .commands (Daml JsCommands)
// Sui does not support unsigned transaction generation
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 FamilyClassLibraryStatus
EVMEVMChainethers.js v6 (viem optional)Supported
SolanaSolanaChainsolana-web3.jsSupported
AptosAptosChainaptos-ts-sdkSupported
SuiSuiChain@mysten/suiPartial (manual exec)
TONTONChain@ton/tonPartial (no token pool/registry queries)
CantonCantonChainCanton Ledger JSON APIPartial (send + manual exec; requires CantonConfig)

License

MIT

版本与发布记录

@chainlink/ccip-sdk 共发布 45 个版本,首次发布于 2025/11/26;过去 12 个月发布了 45 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.16.1latest2026/10/1822 天前
1.16.02026/10/1030 天前
1.15.02026/10/011 个月前
1.14.02026/09/261 个月前
1.13.02026/08/262 个月前
1.12.02026/08/202 个月前

关于 @chainlink/ccip-sdk 的常见问题

@chainlink/ccip-sdk 是什么?

SDK/Library to interact with CCIP

如何安装 @chainlink/ccip-sdk?

在项目目录运行 npm install @chainlink/ccip-sdk,或使用 pnpm add / yarn add / bun add。

@chainlink/ccip-sdk 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@chainlink/ccip-sdk 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@chainlink/ccip-sdk 可以商用吗?

@chainlink/ccip-sdk 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@chainlink/ccip-sdk 的下载量有多少?

根据 npm 官方下载统计,@chainlink/ccip-sdk 在 2026/10/10 – 2026/11/08 这 30 天内被下载 18,216 次,日均约 607 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@chainlink/ccip-sdk 还在维护吗?

最新版本 1.16.1 发布于 2026/10/18(22 天前);至今共发布 45 个版本,其中过去 12 个月发布了 45 个;首次发布于 2025/11/26。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。