ckbtc
БесплатноБез исполняемых скриптовНе проверенAccept, send, and manage ckBTC (chain-key Bitcoin). Covers BTC deposit flow via minter, ckBTC transfers, withdrawal to BTC, subaccount derivation, and UTXO…
от jiayaoqijia★ 81 звезда на GitHubОб этом скилле
Chain-Key Bitcoin (ckBTC) Integration
What This Is
ckBTC is a 1:1 BTC-backed token native to the Internet Computer. No bridges, no wrapping, no third-party custodians. The ckBTC minter canister holds real BTC and mints/burns ckBTC tokens. Transfers settle in 1-2 seconds with a 10 satoshi fee (versus minutes and thousands of satoshis on Bitcoin L1).
Prerequisites
- For Motoko:
mopspackage manager,core = "2.0.0"in mops.toml - For Rust:
ic-cdk,icrc-ledger-types,candid,serde
Canister IDs
Bitcoin Mainnet
| Canister | ID |
|---|---|
| ckBTC Ledger | mxzaz-hqaaa-aaaar-qaada-cai |
| ckBTC Minter | mqygn-kiaaa-aaaar-qaadq-cai |
| ckBTC Index | n5wcd-faaaa-aaaar-qaaea-cai |
| ckBTC Checker | oltsj-fqaaa-aaaar-qal5q-cai |
Bitcoin Testnet4
| Canister | ID |
|---|---|
| ckBTC Ledger | mc6ru-gyaaa-aaaar-qaaaq-cai |
| ckBTC Minter | ml52i-qqaaa-aaaar-qaaba-cai |
| ckBTC Index | mm444-5iaaa-aaaar-qaabq-cai |
How It Works
Deposit Flow (BTC -> ckBTC)
- Call
get_btc_addresson the minter with the user's principal + subaccount. This returns a unique Bitcoin address controlled by the minter. - User sends BTC to that address using any Bitcoin wallet.
- Wait for Bitcoin confirmations (the minter requires confirmations before minting).
- Call
update_balanceon the minter with the same principal + subaccount. The minter checks for new UTXOs and mints equivalent ckBTC to the user's ICRC-1 account.
Transfer Flow (ckBTC -> ckBTC)
Call icrc1_transfer on the ckBTC ledger. Fee is 10 satoshis. Settles in 1-2 seconds.
Withdrawal Flow (ckBTC -> BTC)
- Call
icrc2_approveon the ckBTC ledger to grant the minter canister an allowance to spend from your account. - Call
retrieve_btc_with_approvalon the minter with{ address, amount, from_subaccount: null }. - The minter uses the approval to burn the ckBTC and submits a Bitcoin transaction.
- The BTC arrives at the destination address after Bitcoin confirmations.
Subaccount Generation
Each user gets a unique deposit address derived from their principal + an optional 32-byte subaccount. To give each user a distinct deposit address within your canister, derive subaccounts from a user-specific identifier (their principal or a sequential ID).
Mistakes That Break Your Build
Using the wrong minter canister ID. The minter ID is
mqygn-kiaaa-aaaar-qaadq-cai. Do not confuse it with the ledger (mxzaz-...) or index (n5wcd-...).Forgetting the 10 satoshi transfer fee. Every
icrc1_transferdeducts 10 satoshis beyond the amount. If the user has exactly 1000 satoshis and you transfer 1000, it fails withInsufficientFunds. Transferbalance - 10instead.Not calling
update_balanceafter a BTC deposit. Sending BTC to the deposit address does nothing until you callupdate_balance. The minter does not auto-detect deposits. Your app must call this.Using Account Identifier instead of ICRC-1 Account. ckBTC uses the ICRC-1 standard:
{ owner: Principal, subaccount: ?Blob }. Do NOT use the legacyAccountIdentifier(hex string) from the ICP ledger.Subaccount must be exactly 32 bytes or null. Passing a subaccount shorter or longer than 32 bytes causes a trap. Pad with leading zeros if deriving from a shorter value.
Calling
retrieve_btcwith amount below the minimum. The minter has a minimum withdrawal amount (currently 50,000 satoshis / 0.0005 BTC). Below this, you getAmountTooLow.Not checking the
retrieve_btcresponse for errors. The response is a variant:Okcontains{ block_index },Errcontains specific errors likeMalformedAddress,InsufficientFunds,TemporarilyUnavailable. Always match both arms.Forgetting
owneringet_btc_addressargs. If you omitowner, Candid sub-typing assigns null, and the minter returns the deposit address of the caller (the canister) instead of the user.Leaving
created_at_timenull onicrc1_transfer/icrc2_approve. The ICRC-1 spec says a ledger SHOULD NOT deduplicate a transaction whosecreated_at_timeis unset, so a retried transfer executes a second time and moves real BTC-backed value twice. Set it, and retry with the same timestamp — the ledger only matches duplicates when every argument is identical, so a freshTime.now()on retry defeats dedup. A retry that was already applied returns#Err(#Duplicate { duplicate_of }), which is a success, not a failure.
Implementation
Motoko
mops.toml
[package]
name = "ckbtc-app"
version = "0.1.0"
[dependencies]
core = "2.0.0"
icrc2-types = "1.1.0"
[canisters.backend]
main = "src/backend/main.mo"
The @dfinity/motoko@v5+ recipe compiles via mops build <canister-name>, so main lives here — not in recipe.configuration in icp.yaml. The [canisters.<name>] key must exactly match the canister name in icp.yaml.
icp.yaml
Your backend canister calls the ckBTC ledger
Установить ckbtc в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл ckbtc?
Accept, send, and manage ckBTC (chain-key Bitcoin). Covers BTC deposit flow via minter, ckBTC transfers, withdrawal to BTC, subaccount derivation, and UTXO management. Use when integrating Bitcoin, ckBTC, BTC deposits, or BTC withdrawals in a canister. Do NOT use for plain token transfers without BTC minting/withdrawal — use icrc-ledger instead.
Как установить скилл ckbtc?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл ckbtc запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic