githubEdit

SDK Setup and Installation

👥 Audience: App Developers and Infrastructure Integrators setting up their local environment to build with CBTC on the Canton Network.

⚠️ API Disclaimer. CBTC APIs have no formal versioning policy today. All SDK interfaces described in this guide are subject to change. Breaking changes are communicated via #cbtc-ecosystem and the changelog. This disclaimer will be updated once a formal versioning and stability policy is established.


This page is your single reference for installing and configuring everything you need to build with CBTC. If you've already completed setup, head straight to the Quick Start to mint your first wrapped Bitcoin.


System Requirements

Requirement
Details

Rust toolchain

Latest stable. Install via rustup.rsarrow-up-right

Canton participant node

Running and connected to devnet, testnet, or mainnet. See Canton documentationarrow-up-right

DA Registry Utility

Installed and configured. See Digital Asset Utilities docsarrow-up-right

Keycloak credentials

Host, realm, client ID, username, and password for your environment

Party ID

Your Canton Party ID, obtained during onboarding


Install cbtc-lib (Rust)

cbtc-lib is BitSafe's primary SDK for CBTC operations: minting, burning, transferring, UTXO management, and balance queries. It wraps the Canton Ledger API with type-safe Rust functions.

Add to your project

Add cbtc-lib to your Cargo.toml:

📌 Pin your version. Always reference a specific tag (e.g. v0.3.0) rather than main. The library is under active development and main may contain breaking changes between releases.

Key modules

Module
Purpose

cbtc::mint_redeem::mint

Create deposit accounts, get Bitcoin deposit addresses

cbtc::mint_redeem::redeem

Create withdraw accounts, burn CBTC and withdraw to BTC

cbtc::transfer

Send CBTC to another party (creates transfer offer)

cbtc::accept

Accept incoming CBTC transfer offers

cbtc::active_contracts

Query current CBTC holdings for a party

cbtc::consolidate

Merge multiple UTXO holdings into fewer contracts

cbtc::split

Split a single holding into multiple UTXOs

cbtc::batch

Batch operations for sending to multiple recipients

cbtc::distribute

Distribute CBTC across multiple parties

cbtc::cancel_offers

Cancel pending outgoing transfer offers


Install canton-lib

canton-lib is now a Rust workspace containing multiple crates that cbtc depends on. It handles Canton Ledger API communication, authentication, and Daml contract interactions.

Add to your project

Add the canton-lib crates you need to your Cargo.toml:

The keycloak crate provides authentication helpers used across all CBTC operations.

Password-grant authentication (for user-facing flows):

Client credentials authentication (for service-to-service / backend flows):


Install CBTC DAR Files

DAR (Daml Archive) files contain the smart contract templates that power CBTC on Canton. They must be installed on your participant node before you can interact with CBTC.

Download (v0.3.0): github.com/DLC-link/cbtc-lib/tree/v0.3.0/cbtc-darsarrow-up-right

Install the DAR files on your Canton participant node using the Canton console or your deployment tooling. The specific installation method depends on your Canton setup. Refer to the Canton documentationarrow-up-right for details.

💡 DAR version and Instrument IDs are linked. When DAR files are upgraded on the network, Instrument IDs may change. Always fetch Instrument IDs dynamically from the metadata endpoint rather than hardcoding them. See the Instrument ID Management page for the polling pattern.


Environment Configuration

Set these variables before running any CBTC commands or code. Values differ per environment.

Example .env file


Migration Guide: December 2025 Restructure

In December 2025, cbtc-lib underwent a major restructure led by Ferenc. If you were using an earlier version, you will need to update your imports and module paths.

What changed

  • Module hierarchy was reorganised for clarity

  • Some function signatures were updated

  • canton-lib was extracted as a separate dependency

How to migrate

  1. Update your Cargo.toml to pin to v0.3.0

  2. Update all use statements to match the new module paths (see the module table above)

  3. Review the cleanup PRarrow-up-right for a full diff of changes

⚠️ Breaking change. Code written against pre-restructure cbtc-lib will not compile against v0.3.0 without import updates. There are no runtime behaviour changes, only module paths and function signatures moved.


Verify Your Installation

Run this minimal check to confirm everything is wired up:

If both checks pass, you're ready. Head to the Quick Start to mint your first CBTC.


Next Steps

  • Quick Start: Mint your first wrapped Bitcoin in 15 minutes

  • API Reference: Full Canton Ledger API endpoint documentation

  • Instrument ID Management: How to fetch and poll for the latest CBTC Instrument IDs

  • Authentication Guide: Detailed Keycloak setup and Auth0 community example


Last updated