Skip to content

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.

Install the SDK from npm:

Terminal window
npm install @clearportx/sdk

Create 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}`);

The SDK mirrors the on-chain contract surface:

  • client.dex.swap() — execute a swap with automatic multi-bin routing
  • client.dex.addLiquidity() — deposit into a pool with a chosen strategy
  • client.dex.removeLiquidity() — withdraw from specific bins
  • client.dex.getPools() — list available pools and their current state
  • client.dex.getQuote() — preview a swap without executing
  • client.oracle.getPrice() — read the current validated price for an asset
  • client.wallet.getBalance() — read token balances for the current party

Full method signatures, parameter schemas, and return types are documented in API reference.

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.