# @chainlink/ccip-sdk 中文文档

规范地址：https://npmcn.com/package/%40chainlink/ccip-sdk/

版本：1\.16\.1
npm 元数据更新时间：2026-10-17T21:04:34.475Z
中文译文更新时间：2026-11-09T09:29:43.603Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40chainlink/ccip-sdk
原文对照：https://npmcn.com/package/%40chainlink/ccip-sdk/?lang=original
项目主页：https://docs.chain.link/ccip/tools/sdk/
源码仓库：https://github.com/smartcontractkit/ccip-tools-ts

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：18.6 MB，1857 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- 运行依赖：24 个
- peer 依赖：viem ^2\.0\.0
- 首次发布：2025-11-26T01:35:03.486Z
- 最新版本发布：2026-10-17T21:04:34.127Z
- 近 30 天下载量：18216（2026-10-10 至 2026-11-08，npm 官方下载统计）
- 已发布版本数：45（近 12 个月 45 个）

## 中文简介

与 CCIP 互动的 SDK/图书馆

## 安装

```sh
npm install @chainlink/ccip-sdk
```

也可以使用：`pnpm add @chainlink/ccip-sdk`、`yarn add @chainlink/ccip-sdk`、`bun add @chainlink/ccip-sdk`

## README

# @ chainlink/ cip- sdk

用于集成的脚本 SDK 类型 [中华民国](https://chain.link/cross-chain) (Cross-Chain互操作性协议) 输入您的应用程序.

> \[大 这一工具是在麻省理工学院许可证下提供的,只是为了方便和说明目的.

📖 **[完整的 SDK 文档](https://docs.chain.link/ccip/tools/sdk/)** - 完整的API参考、先进图案和打树引领.

## 安装

```bash
npm install @chainlink/ccip-sdk
```

> \[注\] Node.js v20+需要. v24+ 建议开发(native TypeScript execution).

## 链类

SDK提供统一的 `Chain` 每个块链家族的类界面。 使用 `fromUrl`数字 :

```ts
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',
  },
})
```

## 共同任务

### 跟踪 CCIP 信件

```ts
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)
```

### 获取收费估计

```ts
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())
```

### 发送 Cross- Chin 信件

```ts
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)
```

## 钱包配置

交易发送方法需要特定链的钱包 :

| 链条 | 钱包类型 | 示例 |
| --- | --- | --- |
| EVM( 视频) | `ethers.Signer` | `new Wallet(privateKey, provider)` |
| 索拉纳 | `anchor.Wallet` | `new Wallet(Keypair.fromSecretKey(...))` |
| 自动 | `aptos.Account` | `Account.fromPrivateKey(...)` |
| 广 | `CantonWallet` | 来自配置+可选 Ed25519 外部签名器的政党ID |

### 未签名的交易

对于自定义签名工作流程(例如浏览器钱包、硬件钱包),请使用 `generateUnsigned*` 方法:

```ts
// 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)
}
```

对于浏览器中的EVM链,请从连接的钱包中获取一个签名符:

```ts
const signer = await source.provider.getSigner(0)
```

## 支持的链条

| 链条家族 | 类 | 图书馆 | 状态 |
| --- | --- | --- | --- |
| EVM( 视频) | `EVMChain` | [乙醚.js v6](https://docs.ethers.org/v6/) (单位:千美元)[维姆](https://viem.sh/) 可选) | 支助 |
| 索拉纳 | `SolanaChain` | [(原始内容存档于2013-10-12). solana-web3.js](https://github.com/solana-foundation/solana-web3.js) | 支助 |
| 自动 | `AptosChain` | [aptos-ts-sdk (英语)](https://github.com/aptos-labs/aptos-ts-sdk) | 支助 |
| 苏 | `SuiChain` | [@mysten/sui (英语)](https://github.com/MystenLabs/sui) | 部分(手工执行) |
| 顿 | `TONChain` | [@ ton/ ton](https://github.com/ton-org/ton) | 部分(没有签名池/登记查询) |
| 广 | `CantonChain` | 州长JSON API | 部分( 发送 + 手动执行; 需要) `CantonConfig`(中文(简体) ) |

## 相关

-   [SDK API 参考文献](https://docs.chain.link/ccip/tools/sdk/) - 完整的SDK文档
-   [@ chainlink/ ccip- cli](https://www.npmjs.com/package/@chainlink/ccip-cli) - 命令线接口
-   [CCIP 官方文件](https://docs.chain.link/ccip) - 礼宾文件
-   [CCIP 目录](https://docs.chain.link/ccip/directory) - 路由器地址

## 许可证

麻省理工学院

## 常见问题

### @chainlink/ccip-sdk 是什么？

与 CCIP 互动的 SDK/图书馆

### 如何安装 @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 和提交记录判断。

