- Npm
First, install dependencies and set up the environment (this will create the .mops, .bitcoin, and .canisters directories):
make installNext, download all required canister WASMs:
make downloadTip: You will need a separate terminal window for each of the following processes:
bitcoind(Bitcoin node)dfx start(Internet Computer local replica)- Any other commands/scripts (e.g.,
make mine)
See: IC Docs: Local Bitcoin Development
Note: You may need to sign the binaries to run them on macOS:
codesign -s - ./.bitcoin/bitcoin-27.0/bin/bitcoind
codesign -s - ./.bitcoin/bitcoin-27.0/bin/bitcoin-cli
Then let's launch the Bitcoin Core daemon (bitcoind) in "regtest" mode. This boots a self-contained Bitcoin Core node for local testing, and isolates all its files to your working directory.
./.bitcoin/bitcoin-27.0/bin/bitcoind \
-conf="$(pwd)/.bitcoin/bitcoin-27.0/bitcoin.conf" \
-datadir="$(pwd)/.bitcoin/bitcoin-27.0/data" \
--port=18444Note: You'll want this to run in its own window as starting up Bitcoin with dfx has noisy logging!
dfx start --background --cleanIn yet another new terminal, deploy the canisters:
make deployInstead of manually generating blocks, use the provided script to mine blocks every 10 seconds:
make mineThis command mine a block and sends the rewards to the deposit ck address on the ckMint (note: canisters must deployed first):
./.bitcoin/bitcoin-27.0/bin/bitcoin-cli \
-conf=$(pwd)/.bitcoin/bitcoin-27.0/bitcoin.conf \
generatetoaddress 1 $(dfx canister call cycle-btc ck_deposit_address | sed 's/[(")]//g')Mint ckBTC (after sending BTC to the deposit address):
dfx canister call cycle-btc mint_ckCheck ckBTC balance:
dfx canister call ck-btc icrc1_balance_of '(record { owner = principal "umunu-kh777-77774-qaaca-cai"})'