Skip to content

Commit 96c8d67

Browse files
authored
doc(basic_bitcoin): add icp ninja link (#1234)
Changes to the basic_bitcoin example README.md: * Add a link to ICP ninja * Remove reference to pre-deployed canister * Fix invalid candid args in get_block_headers command * Fix invalid regtest address
1 parent b243706 commit 96c8d67

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

rust/basic_bitcoin/README.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,13 @@ For background on the ICP<>BTC integration, refer to the [Learn Hub](https://lea
3838
- [x] [Local Bitcoin testnet (regtest)](https://internetcomputer.org/docs/build-on-btc/btc-dev-env#create-a-local-bitcoin-testnet-regtest-with-bitcoind)
3939
- [x] On macOS, an `llvm` version that supports the `wasm32-unknown-unknown` target is required. This is because the Rust `bitcoin` library relies on the `secp256k1-sys` crate, which requires `llvm` to build. The default `llvm` version provided by XCode does not meet this requirement. Instead, install the [Homebrew version](https://formulae.brew.sh/formula/llvm), using `brew install llvm`.
4040

41-
## Building and deploying the smart contract
41+
## Deploying from ICP Ninja
42+
43+
This example can be deployed directly to the Internet Computer using ICP Ninja, where it will connect to Bitcoin **testnet4**. Note: Canisters deployed using ICP Ninja remain live for 50 minutes after signing in with your Internet Identity (accessible via the top-right button in ICP Ninja).
44+
45+
[![](https://icp.ninja/assets/open.svg)](https://icp.ninja/editor?g=https://github.com/dfinity/examples/tree/master/rust/basic_bitcoin)
46+
47+
## Building and deploying the smart contract locally
4248

4349
### 1. Clone the examples repo
4450

@@ -55,9 +61,9 @@ dfx start --enable-bitcoin --bitcoin-node 127.0.0.1:18444
5561
```
5662
This starts a local canister execution environment with Bitcoin support enabled.
5763

58-
### 3. Start the Bitcoin testnet (regtest)
64+
### 3. Start Bitcoin regtest
5965

60-
Open another terminal window (terminal 2) and run the following to start the local Bitcoin testnet:
66+
Open another terminal window (terminal 2) and run the following to start the local Bitcoin regtest network:
6167

6268
```bash
6369
bitcoind -conf=$(pwd)/bitcoin.conf -datadir=$(pwd)/bitcoin_data --port=18444
@@ -78,11 +84,6 @@ What this does:
7884

7985
Your smart contract is live and ready to use! You can interact with it using either the command line or the Candid UI (the link you see in the terminal).
8086

81-
> [!NOTE]
82-
> You can also interact with a pre-deployed version of the `basic_bitcoin` example running on the IC mainnet and configured to interact with Bitcoin **testnet4**.
83-
>
84-
> Access the Candid UI of the example: https://a4gq6-oaaaa-aaaab-qaa4q-cai.raw.icp0.io/?id=vvha6-7qaaa-aaaap-ahodq-cai
85-
8687
## Generating Bitcoin addresses
8788

8889
The example demonstrates how to generate and use the following address types:
@@ -139,7 +140,7 @@ Example:
139140

140141
```bash
141142
dfx canister call basic_bitcoin send_from_p2pkh_address '(record {
142-
destination_address = "tb1ql7w62elx9ucw4pj5lgw4l028hmuw80sndtntxt";
143+
destination_address = "bcrt1qg8qknn6f3txqg97gt8ca0ctya0vw7ep6d02qmt";
143144
amount_in_satoshi = 4321;
144145
})'
145146
```
@@ -158,9 +159,9 @@ The function returns the transaction ID. When interacting with the contract depl
158159
You can query historical block headers:
159160
160161
```bash
161-
dfx canister call basic_bitcoin get_block_headers '(10: nat32)'
162+
dfx canister call basic_bitcoin get_block_headers '(10: nat32, null)'
162163
# or a range:
163-
dfx canister call basic_bitcoin get_block_headers '(0: nat32, 11: nat32)'
164+
dfx canister call basic_bitcoin get_block_headers '(10: nat32, opt (11: nat32))'
164165
```
165166
166167
This calls `bitcoin_get_block_headers`, which is useful for blockchain validation or light client logic.

rust/basic_bitcoin/dfx.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
],
1515
"package": "basic_bitcoin",
1616
"type": "custom",
17-
"wasm": "target/wasm32-unknown-unknown/release/basic_bitcoin.wasm"
17+
"wasm": "target/wasm32-unknown-unknown/release/basic_bitcoin.wasm",
18+
"init_arg": "(variant { testnet })"
1819
}
1920
},
2021
"defaults": {

0 commit comments

Comments
 (0)