SDK overview
The ClearPortX SDK provides a typed, ergonomic interface to every ClearPortX contract. It handles party management, command construction, offset tracking, and response decoding so that your application can focus on business logic.
Quick start
Section titled “Quick start”Install the SDK from npm:
npm install @clearportx/sdkCreate a client instance with your Canton participant node connection details:
import { ClearPortXClient } from '@clearportx/sdk';
const client = new ClearPortXClient({ ledgerUrl: 'https://participant.your-org.example', partyId: 'your-party::namespace', authToken: process.env.CANTON_AUTH_TOKEN!,});Execute a swap in one call:
const result = await client.dex.swap({ fromToken: 'CC', toToken: 'cBTC', amountIn: '500.0', slippageBps: 50, // 0.5%});
console.log(`Received: ${result.amountOut}`);Feature coverage
Section titled “Feature coverage”The SDK mirrors the on-chain contract surface:
client.dex.swap()— execute a swap with automatic multi-bin routingclient.dex.addLiquidity()— deposit into a pool with a chosen strategyclient.dex.removeLiquidity()— withdraw from specific binsclient.dex.getPools()— list available pools and their current stateclient.dex.getQuote()— preview a swap without executingclient.oracle.getPrice()— read the current validated price for an assetclient.wallet.getBalance()— read token balances for the current party
Reference
Section titled “Reference”Full method signatures, parameter schemas, and return types are documented in API reference.
Daml package dependencies
Section titled “Daml package dependencies”If you are writing your own Daml package that imports ClearPortX types, see the package index on our public repository for the canonical package_name and current version.