Skip to content

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.

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

Instead of generic queries, this example wraps them in domain-specific hooks for cleaner code:

reactor.ts
export const { useActorQuery: useCkbtcLedgerQuery } =
createActorHooks(ckbtcLedger)
export const { useActorMutation: useMinterMutation } = createActorHooks(minter)
// App.tsx
const { data: balance } = useCkbtcLedgerQuery({
functionName: "icrc1_balance_of",
args: [{ owner: userPrincipal, subaccount: [] }],
refetchInterval: 5000, // Poll for balance updates
})