@debridge-finance/intents-client

中文文档
2.0.0发布于 2026/10/22TypeScriptESM + CJS近 30 天下载 2796

SDK for working with the intents program in Solana. Allows creating, managing, and executing intents for cross-chain operations.

原始使用文档
文档目录11 节
  1. Installation
  2. File Structure and Usage Flow
  3. 1. 01-init-intent-client.ts - Client Initialization
  4. 2. 02-init-intent.ts - Intent Configuration
  5. 3. 03-create-intent.ts - Intent Creation and Deployment
  6. 4. 05-sandwich-swap.ts - Swap Execution
  7. 5. 06-intent-execution.ts - Intent Execution
  8. Call Sequence
  9. Step-by-Step Execution Flow:
  10. Intent versions
  11. IntentsClient methods

Intents Client SDK

SDK for working with the intents program in Solana. Allows creating, managing, and executing intents for cross-chain operations.

Installation

npm install @debridge-finance/intents-client

File Structure and Usage Flow

The examples folder contains a sequence of files that demonstrate the complete workflow for using the Intents Client SDK. Each file represents a specific step in the process:

1. 01-init-intent-client.ts - Client Initialization

Purpose: Sets up the basic client configuration Contains:

  • new IntentsClient() - Instantiates the intents client

2. 02-init-intent.ts - Intent Configuration

Purpose: Defines the intent structure and parameters Contains:

  • No client methods called

3. 03-create-intent.ts - Intent Creation and Deployment

Purpose: Creates and deploys the intent to the blockchain Contains:

  • client.createAndUpdateIntentTxs() - Creates single transaction (preferred)
  • client.createIntentTxs() - Creates multiple transactions (fallback)

4. 05-sandwich-swap.ts - Swap Execution

Purpose: Performs token swaps using the created intent Contains:

  • client.swapTxs() - Generates swap transaction

5. 06-intent-execution.ts - Intent Execution

Purpose: Final step of executing the intent through DLN Contains:

  • client.executeIntentIxs() - Generates execution instructions

Call Sequence

Step-by-Step Execution Flow:

  1. Initialize Client (01-init-intent-client.ts)

    • Create Solana connection
    • Generate keypair
    • Instantiate IntentsClient
  2. Configure Intent (02-init-intent.ts)

    • Define Intent object with all parameters
    • Set token addresses, amounts, and cross-chain details
  3. Deploy Intent (03-create-intent.ts)

    • Serialize intent data
    • Try single transaction creation
    • Fall back to multi-transaction if needed
    • Send transactions to blockchain
  4. Execute Swap (04-sandwich-swap.ts)

    • Set up token accounts
    • Create swap transaction with intent
    • Execute the swap
  5. Complete Intent (05-intent-execution.ts)

    • Initialize DLN client
    • Create cross-chain order
    • Generate final execution instructions

Intent versions

Intent carries its wire format version: it is passed to the constructor and to Intent.deserialize. The program accepts both v0 and v1 for new intents: the version is passed to initIntent* (take it from intent.version), recorded in the intent storage and used to decode the intent at seal and later on; a payload that does not match the recorded version is rejected. In v1 every exact price is a fraction: output = input * price / 10^priceDenominator, where priceDenominator is in 0..=38:

const intent = new Intent(
  {
    // ...
    giveTokens: [{ output: USDC, input: USDT, price: 1n, priceDenominator: 0 }],
  },
  IntentVersion.V1,
);
const encoded = intent.serialize();

v0 intents (price is scaled by the input mint decimals, no priceDenominator) are still decoded.

Intent<V> and IntentType<V> are generic over the version, so exact prices are checked at compile time: priceDenominator is required for IntentVersion.V1 and not allowed for IntentVersion.V0 (the 0..=38 range is checked by serialize()).

The intent storage account keeps everything needed to decode the intent: the owner (maker), the version recorded at init (version) and the encoded intent (storedIntent.ready|cancelled, returned as encodedIntent):

const storage = await client.getIntentStorage(connection, intentId);
// storage.encodedIntent is null while the storage is not initialized
const { maker, version, encodedIntent } = storage!;
switch (version) {
  case IntentVersion.V0:
    // Intent<IntentVersion.V0>
    Intent.deserialize(encodedIntent!, maker, IntentVersion.V0);
    break;
  case IntentVersion.V1:
    // Intent<IntentVersion.V1>: exact prices have priceDenominator
    Intent.deserialize(encodedIntent!, maker, IntentVersion.V1);
    break;
}

IntentsClient methods

  • getState()
  • getIntentStorage()
  • executeIntentIxs()
  • initIntentIxs()
  • initIntentUsingSigIxs()
  • setDelegateApprovedBudgetsIxs()
  • swapBeginIxs()
  • swapEndIxs()
  • updateIntentIxs()
  • closeRecordIxs()
  • writeRecordIxs()
  • reallocRecordIxs()
  • initIntentTxs()
  • writeIntentTxs()
  • createIntentTxs()
  • createAndUpdateIntentTxs()
  • updateRecordTxs()
  • closeIntentTxs()
  • swapTxs()

版本与发布记录

@debridge-finance/intents-client 共发布 34 个版本,首次发布于 2025/08/26;过去 12 个月发布了 22 个版本。

版本发布日期距今
2.0.0latest2026/10/2220 天前
1.8.02026/07/084 个月前
1.8.0-rc.0beta2026/05/016 个月前
1.7.02026/04/156 个月前
1.6.6-rc.02026/03/098 个月前
1.6.52026/02/208 个月前

关于 @debridge-finance/intents-client 的常见问题

@debridge-finance/intents-client 是什么?

SDK for working with the intents program in Solana. Allows creating, managing, and executing intents for cross-chain operations.

如何安装 @debridge-finance/intents-client?

在项目目录运行 npm install @debridge-finance/intents-client,或使用 pnpm add / yarn add / bun add。

@debridge-finance/intents-client 支持 TypeScript 吗?

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

@debridge-finance/intents-client 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@debridge-finance/intents-client 可以商用吗?

@debridge-finance/intents-client 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@debridge-finance/intents-client 的下载量有多少?

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

@debridge-finance/intents-client 还在维护吗?

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