For the complete documentation index, see llms.txt. This page is also available as Markdown.

SDK Setup and Installation

⚠️ 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 the changelog.


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.rs

Canton participant node

Running and connected to devnet, testnet, or mainnet. See Canton documentation

DA Registry Utility

Installed and configured. See Digital Asset Utilities docs

Keycloak credentials

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

Party ID

Your Canton Party ID, obtained during onboarding

Minter credential

Only required to mint or burn CBTC. Issued to your party by the CBTC registrar; request one via sales@bitsafe.finance. Holding, sending, and receiving CBTC do not require it.


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.6.4) 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

cbtc::credentials

List and accept Minter credentials (required to mint or burn)

cbtc::allocation

Allocate CBTC into DvP settlement legs (delivery-versus-payment)


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:

📌 Match the tag cbtc-lib depends on. cbtc-lib v0.6.4 pins canton-lib v0.6.1. If you add these crates at a different tag than the one cbtc-lib uses, Cargo will resolve two incompatible copies of the same types and your build will fail with confusing mismatched-type errors.

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: github.com/DLC-link/cbtc-lib/tree/v0.6.4/cbtc-dars

The latest CBTC DAR is cbtc-1.2.1, shipped in cbtc-lib v0.6.4. DAR versions and crate versions are numbered independently.

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 documentation for details.

💡 Install every DAR version, not just the newest. The repository ships all released DARs (cbtc-1.0.0 through cbtc-1.2.1). Older versions are required to interact with contracts still live on the network from earlier releases. You can verify what your participant is missing with the cbtc::dar_check module.

💡 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.

Variable
Devnet
Testnet
Mainnet

💡 BITSAFE_API_URL is the BitSafe API gateway, which serves the /cbtc/v1/* endpoints behind deposit accounts, deposit addresses, and withdrawals. cbtc-lib reads it and passes it as the api_url parameter to get_account_contract_rules, get_bitcoin_address, and submit_withdraw. An Attestor or Coordinator host will not work in its place.

Example.env file


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


Last updated