ckBTC Wallet
A specialized wallet interface for ckBTC (Chain Key Bitcoin). This example demonstrates how to build a finance-ready dApp that interacts with the ckBTC ledger and minter canisters.
Features Demonstrated
Section titled “Features Demonstrated”- ICRC-1 Standard: Interacting with the standard token interface (balance, transfer).
- ckBTC Specifics: Retrieving BTC addresses and updating balances.
- Complex Flows: Managing deposit/withdraw cycles.
- Floating Point Math: Handling token decimals correctly in the UI.
Open in StackBlitzEdit and run in your browser
View on GitHubBrowse the source code
Live Preview
Section titled “Live Preview”Key Design Patterns
Section titled “Key Design Patterns”Domain Specific Hooks
Section titled “Domain Specific Hooks”Instead of generic queries, this example wraps them in domain-specific hooks for cleaner code:
// Ledger hooks, bound to the ckBTC ledger DisplayReactorexport const { useActorQuery: useCkbtcLedgerQuery } = createActorHooks(ckbtcLedger)
// Reusable query/mutation objects for the two canistersexport const balanceQuery = createQueryFactory(ckbtcLedger, { functionName: "icrc1_balance_of",})
export const updateBalanceMutation = createMutation(ckbtcMinter, { functionName: "update_balance",})
// src/App.tsxconst { data: name } = useCkbtcLedgerQuery({ functionName: "icrc1_name",})
// src/MinterRetrieveBtc.tsx — `owner` is a plain string under DisplayReactorconst { data: balance, refetch: refetchBalance } = balanceQuery([ { owner: userPrincipal },]).useQuery()