You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[View this sample's code on GitHub](https://github.com/dfinity/examples/tree/master/motoko/basic_bitcoin)
8
-
9
-
## Overview
10
3
This tutorial will walk you through how to deploy a sample [canister smart contract](https://wiki.internetcomputer.org/wiki/Canister_smart_contract)**that can send and receive Bitcoin** on the Internet Computer.
11
4
12
5
## Architecture
@@ -21,22 +14,23 @@ For a deeper understanding of the ICP < > BTC integration, see the [Bitcoin inte
21
14
22
15
## Prerequisites
23
16
24
-
*[x] Install the [IC
25
-
SDK](https://internetcomputer.org/docs/current/developer-docs/setup/install/index.mdx). For local testing, `dfx >= 0.22.0` is required.
17
+
-[x] Install the [IC
18
+
SDK](https://internetcomputer.org/docs/current/developer-docs/getting-started/install). For local testing, `dfx >= 0.22.0` is required.
19
+
-[x] Clone the example dapp project: `git clone https://github.com/dfinity/examples`
20
+
21
+
> [!WARNING]
22
+
> This example is designed to be deployed on the mainnet. It will return errors when deployed locally; these errors are expected.
26
23
27
-
:::info
28
-
This example is designed to be deployed on the mainnet. It will return errors when deployed locally; these errors are expected.
29
-
:::
24
+
Begin by opening a terminal window.
30
25
31
-
## Step 1: Building and deploying sample code
26
+
## Step 1: Setup the project environment
32
27
33
-
### Clone the smart contract
28
+
Navigate into the folder containing the project's files and start a local instance of the Internet Computer with the commands:
34
29
35
-
To clone and build the smart contract in **Motoko**:
[View this sample's code on GitHub](https://github.com/dfinity/examples/tree/master/motoko/basic_dao)
8
-
9
3
This sample project demonstrates a basic [decentralized autonomous organization](https://en.wikipedia.org/wiki/Decentralized_autonomous_organization) (DAO) that can be deployed to the [Internet Computer](https://github.com/dfinity/ic). The basic DAO sample code is available in [Motoko](https://github.com/dfinity/examples/tree/master/motoko/basic_dao) and [Rust](https://github.com/dfinity/examples/tree/master/rust/basic_dao). You can see a quick introduction on [YouTube](https://youtu.be/3IcYlieA-EE).
10
4
11
-
## Overview
12
-
13
5
A `basic_dao` can be initialized with a set of accounts: mappings from principal IDs to a number of tokens. Account owners can query their account balance by calling `account_balance` and transfer tokens to other accounts by calling `transfer`. Anyone can call `list_accounts` to view all accounts.
14
6
15
7
Account owners can submit proposals by calling `submit_proposal`. A proposal specifies a canister, method, and arguments for this method. Account owners can cast votes (either `Yes` or `No`) on a proposal by calling `vote`. The amount of votes cast is equal to the amount of tokens the account owner has. If enough `Yes` votes are cast, `basic_dao` will execute the proposal by calling the proposal’s given method with the given args against the given canister. If enough `No` votes are cast, the proposal is not executed, and is instead marked as `Rejected`.
@@ -19,30 +11,35 @@ This workflow is demonstrated below.
19
11
20
12
View the [canister service definition](https://github.com/dfinity/examples/blob/master/rust/basic_dao/src/basic_dao/src/basic_dao.did) for more details.
21
13
22
-
### Prerequisites
23
-
This example requires an installation of:
14
+
## Prerequisites
24
15
25
-
-[x] Install the [IC SDK](https://internetcomputer.org/docs/current/developer-docs/setup/install/).
16
+
-[x] Install the [IC
17
+
SDK](https://internetcomputer.org/docs/current/developer-docs/getting-started/install). For local testing, `dfx >= 0.22.0` is required.
26
18
-[x] To run the test scripts, you need to download [ic-repl](https://github.com/chenyan2002/ic-repl/releases).
27
19
-[x] Clone the example dapp project: `git clone https://github.com/dfinity/examples`
28
20
29
21
Begin by opening a terminal window.
30
22
31
-
### Step 1: Navigate into the folder containing the project's files and start a local instance of the Internet Computer with the command:
23
+
## Step 1: Setup the project environment
24
+
25
+
Navigate into the folder containing the project's files and start a local instance of the Internet Computer with the commands:
26
+
32
27
33
28
```bash
34
29
cd examples/motoko/basic_dao
35
30
dfx start --background
36
31
```
37
32
38
-
### Step 2: Create test identities with the commands:
33
+
## Step 2: Create identities
34
+
35
+
Create test identities with the commands:
39
36
40
37
```bash
41
38
dfx identity new Alice --disable-encryption; dfx identity use Alice;export ALICE=$(dfx identity get-principal);
42
39
dfx identity new Bob --disable-encryption; dfx identity use Bob;export BOB=$(dfx identity get-principal);
43
40
```
44
41
45
-
###Step 3: Deploy `basic_dao` with initial test accounts.
42
+
##Step 3: Deploy `basic_dao` with initial test accounts
In order not to call `dfx canister logs CanisterLogs` after every canister call in a separate terminal window/pane C start a script that will constantly poll logs:
76
74
@@ -86,25 +84,25 @@ $ ./poll_logs.sh
86
84
...
87
85
```
88
86
89
-
###Step 6: Call `print`, `trap` and other canister methods:
87
+
## Step 6: Call `print`, `trap` and other canister methods
90
88
91
89
```shell
92
90
# Terminal B
93
-
$ dfx canister call CanisterLogs print hi!
91
+
dfx canister call CanisterLogs print hi!
94
92
()
95
93
96
-
$ dfx canister call CanisterLogs print hello!
94
+
dfx canister call CanisterLogs print hello!
97
95
()
98
96
99
-
$ dfx canister call CanisterLogs print yey!
97
+
dfx canister call CanisterLogs print yey!
100
98
()
101
99
102
-
$ dfx canister call CanisterLogs trap oops!
100
+
dfx canister call CanisterLogs trap oops!
103
101
Error: Failed update call.
104
102
Caused by: Failed update call.
105
103
The replica returned a rejection error: reject code CanisterError, reject message Canister bkyz2-fmaaa-aaaaa-qaaaq-cai trapped explicitly: oops!, error code None
106
104
107
-
$ dfx canister call CanisterLogs memory_oob
105
+
dfx canister call CanisterLogs memory_oob
108
106
Error: Failed update call.
109
107
Caused by: Failed update call.
110
108
The replica returned a rejection error: reject code CanisterError, reject message Canister bkyz2-fmaaa-aaaaa-qaaaq-cai trapped explicitly: StableMemory range out of bounds, error code None
0 commit comments