@debridge-finance/intents-client
v1.3.0
Published
SDK for working with the intents program in Solana. Allows creating, managing, and executing intents for cross-chain operations.
Downloads
858
Maintainers
Keywords
Readme
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-clientFile 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:
Initialize Client (
01-init-intent-client.ts)- Create Solana connection
- Generate keypair
- Instantiate IntentsClient
Configure Intent (
02-init-intent.ts)- Define Intent object with all parameters
- Set token addresses, amounts, and cross-chain details
Deploy Intent (
03-create-intent.ts)- Serialize intent data
- Try single transaction creation
- Fall back to multi-transaction if needed
- Send transactions to blockchain
Execute Swap (
04-sandwich-swap.ts)- Set up token accounts
- Create swap transaction with intent
- Execute the swap
Complete Intent (
05-intent-execution.ts)- Initialize DLN client
- Create cross-chain order
- Generate final execution instructions
IntentsClient methods
- getState()
- getIntentStorage()
- executeIntentIxs()
- initIntentIxs()
- initIntentUsingSigIxs()
- setDelegateApprovedBudgetsIxs()
- swapBeginIxs()
- swapEndIxs()
- updateIntentIxs()
- closeRecordIxs()
- writeRecordIxs()
- reallocRecordIxs()
- initIntentTxs()
- writeIntentTxs()
- createIntentTxs()
- createAndUpdateIntentTxs()
- updateRecordTxs()
- closeIntentTxs()
- swapTxs()
