Overview
ckBTC combines the value of Bitcoin with the programmability and efficiency of the Internet Computer:- 1:1 Backed: Every ckBTC token is backed by real BTC held in the minter’s custody
- Fast Transactions: ckBTC transfers finalize in 1-2 seconds
- Low Fees: Transaction fees are ~0.0000001 BTC compared to on-chain Bitcoin fees
- Programmable: Can be used in canister smart contracts and DeFi applications
Architecture
Minter Canister
The ckBTC minter (rs/bitcoin/ckbtc/minter) is the core component managing conversions between BTC and ckBTC.
Key Responsibilities
BTC → ckBTC
Detects Bitcoin deposits and mints ckBTC tokens
ckBTC → BTC
Burns ckBTC and sends Bitcoin to destination addresses
UTXO Management
Tracks and manages Bitcoin UTXOs owned by the minter
Fee Estimation
Estimates Bitcoin transaction fees dynamically
Minter Configuration
Configuration Parameters
Configuration Parameters
- btc_network: Bitcoin network (Mainnet/Testnet/Regtest)
- ledger_id: Principal of the ckBTC ledger canister
- ecdsa_key_name: Name of the threshold ECDSA key to use
- deposit_btc_min_amount: Minimum BTC amount for deposits (prevents dust)
- retrieve_btc_min_amount: Minimum ckBTC amount for withdrawals
- max_time_in_queue_nanos: Maximum time a withdrawal can be queued
- min_confirmations: Required confirmations for Bitcoin transactions (default: 12)
- mode: Operation mode (ReadOnly/RestrictedTo/GeneralAvailability)
- check_fee: Fee charged for Bitcoin address validation
- btc_checker_principal: Optional KYC/AML checker canister
BTC to ckBTC (Deposit)
Users deposit Bitcoin to a unique address controlled by the minter to receive ckBTC.Deposit Process
Get Bitcoin Address
Call Each IC account (principal + subaccount) maps to a unique Bitcoin address.
get_btc_address to obtain a unique Bitcoin address:Wait for Confirmations
Wait for the required number of confirmations (typically 12 blocks, ~2 hours).
UTXO Processing
The minter processes UTXOs in several states:UTXO Status Meanings
UTXO Status Meanings
- ValueTooSmall: UTXO value is below the minimum deposit amount
- Tainted: UTXO flagged by the Bitcoin checker (KYC/AML)
- Checked: UTXO passed checks but minting not yet complete
- Minted: ckBTC successfully minted, includes ledger block index
ckBTC to BTC (Withdrawal)
Users burn ckBTC to receive Bitcoin at a specified address.Withdrawal Process
Request Withdrawal
Call Returns a
retrieve_btc_with_approval to initiate withdrawal:block_index for tracking the withdrawal.Withdrawal States
Withdrawal Status Flow
Withdrawal Status Flow
- Pending: Request queued, waiting to be batched
- Signing: Obtaining threshold ECDSA signature
- Sending: Signed transaction being broadcast
- Submitted: Transaction submitted to Bitcoin network
- Confirmed: Transaction confirmed on Bitcoin blockchain
- Reimbursed: Failed transaction, ckBTC refunded
Transaction Batching
- Waits for at least 20 pending requests before creating a batch
- Includes up to 100 requests in a single Bitcoin transaction
- Distributes transaction fees across all recipients
- Creates change outputs back to the minter
UTXO Management
The minter maintains a pool of UTXOs for efficient transaction construction.UTXO Selection Algorithm
- Greedily selects smallest UTXOs that sum to at least the target amount
- If managing >1,000 UTXOs, matches input count to output count + 1
- Returns empty vector if insufficient funds
UTXO Consolidation
- UTXO count exceeds the threshold
- At least 24 hours have passed since last consolidation
- Bitcoin network fees are reasonable
Consolidation reduces future transaction fees by combining many small UTXOs into fewer large ones.
Fee Structure
Deposit Fees
When converting BTC → ckBTC:- Bitcoin Transaction Fee: Paid by the user when sending BTC
- Check Fee: Optional fee for KYC/AML validation (if enabled)
- Ledger Fee: 10 satoshis for minting ckBTC
Withdrawal Fees
When converting ckBTC → BTC:- Current Bitcoin network fee rate (from Bitcoin canister)
- Transaction size (inputs + outputs)
- Required confirmations
Fee Distribution
- Each recipient pays a proportional share
- Remainder distributed to early recipients
- Example: distribute(5 satoshis, 3 recipients) = [2, 2, 1]
Transaction Building
The minter constructs Bitcoin transactions with multiple outputs.Unsigned Transaction
Transaction Features
- RBF Enabled
- Change Outputs
- Fee Estimation
Replace-By-Fee (RBF) allows resubmitting with higher fees:Used when transactions get stuck in the mempool.
Transaction Resubmission
- Wait at least 24 hours
- Check if transaction is in mempool (0 confirmations)
- Create replacement transaction with higher fee
- Increase fee by at least 10% from previous attempt
- Resubmit to Bitcoin network
Security Features
Address Validation
- Correct format (P2PKH, P2SH, P2WPKH, P2WSH, P2TR)
- Network compatibility (mainnet vs testnet)
- Optional KYC/AML screening via Bitcoin checker
Transaction Limits
- Maximum inputs: Prevents creating non-standard transactions >100KB
- Minimum withdrawal: Ensures amount covers Bitcoin transaction fees
- Dust limit: Prevents outputs too small for the Bitcoin network
Reimbursement System
Failed transactions are automatically reimbursed:- Bitcoin checker rejects the destination address
- Transaction building fails (e.g., too many inputs)
- Ledger calls fail during processing
Event Logging
The minter maintains a comprehensive event log for auditability.Event Types
Querying Events
Candid Interface
Core Methods
- Deposit
- Withdraw
- Info
Related Components
Bitcoin Integration
Underlying Bitcoin protocol integration
ICRC-1 Ledger
ckBTC implements the ICRC-1 token standard
Source Code Reference
Key files in the ckBTC implementation:rs/bitcoin/ckbtc/minter/src/lib.rs- Main minter logicrs/bitcoin/ckbtc/minter/src/state/- State managementrs/bitcoin/ckbtc/minter/src/updates/- Update call handlersrs/bitcoin/ckbtc/minter/src/queries/- Query call handlersrs/bitcoin/ckbtc/minter/src/tx.rs- Transaction buildingrs/bitcoin/ckbtc/minter/ckbtc_minter.did- Candid interface