Skip to content

Commit e876b1a

Browse files
Update Motoko project READMEs
1 parent 786c2e9 commit e876b1a

File tree

28 files changed

+429
-651
lines changed

28 files changed

+429
-651
lines changed

archive/motoko/persistent-storage/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ This example requires an installation of:
3333

3434
Begin by opening a terminal window.
3535

36-
### Step 1: Navigate into the folder containing the project's files and start a local instance of the Internet Computer with the command:
36+
### Step 1: Navigate into the folder containing the project's files and start a local instance of the Internet Computer with the commands:
37+
3738

3839
```bash
3940
cd examples/motoko/persistent-storage

motoko/basic_bitcoin/README.md

+10-16
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
1-
---
2-
keywords: [advanced, motoko, bitcoin, bitcoin integration, btc]
3-
---
4-
51
# Basic Bitcoin
62

7-
[View this sample's code on GitHub](https://github.com/dfinity/examples/tree/master/motoko/basic_bitcoin)
8-
9-
## Overview
103
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.
114

125
## Architecture
@@ -21,22 +14,23 @@ For a deeper understanding of the ICP < > BTC integration, see the [Bitcoin inte
2114

2215
## Prerequisites
2316

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.
2623
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.
3025

31-
## Step 1: Building and deploying sample code
26+
## Step 1: Setup the project environment
3227

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:
3429

35-
To clone and build the smart contract in **Motoko**:
3630

3731
```bash
38-
git clone https://github.com/dfinity/examples
3932
cd examples/motoko/basic_bitcoin
33+
dfx start --background
4034
```
4135

4236
### Install MOPS

motoko/basic_dao/README.md

+12-15
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
1-
---
2-
keywords: [advanced, motoko, dao, decentralized organization, decentralized org]
3-
---
4-
51
# Basic DAO
62

7-
[View this sample's code on GitHub](https://github.com/dfinity/examples/tree/master/motoko/basic_dao)
8-
93
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).
104

11-
## Overview
12-
135
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.
146

157
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.
1911

2012
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.
2113

22-
### Prerequisites
23-
This example requires an installation of:
14+
## Prerequisites
2415

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.
2618
- [x] To run the test scripts, you need to download [ic-repl](https://github.com/chenyan2002/ic-repl/releases).
2719
- [x] Clone the example dapp project: `git clone https://github.com/dfinity/examples`
2820

2921
Begin by opening a terminal window.
3022

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+
3227

3328
```bash
3429
cd examples/motoko/basic_dao
3530
dfx start --background
3631
```
3732

38-
### Step 2: Create test identities with the commands:
33+
## Step 2: Create identities
34+
35+
Create test identities with the commands:
3936

4037
```bash
4138
dfx identity new Alice --disable-encryption; dfx identity use Alice; export ALICE=$(dfx identity get-principal);
4239
dfx identity new Bob --disable-encryption; dfx identity use Bob; export BOB=$(dfx identity get-principal);
4340
```
4441

45-
### Step 3: Deploy `basic_dao` with initial test accounts.
42+
## Step 3: Deploy `basic_dao` with initial test accounts
4643

4744
```bash
4845
dfx deploy --argument "(record {
@@ -57,7 +54,7 @@ dfx deploy --argument "(record {
5754
})"
5855
```
5956

60-
### Step 4: Run the ic-repl test scripts:
57+
## Step 4: Run the `ic-repl` test scripts:
6158

6259
```bash
6360
ic-repl tests/account.test.sh

motoko/canister_logs/README.md

+31-33
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,64 @@
1-
---
2-
keywords: [beginner, motoko, canister logs, logging]
3-
---
4-
51
# Canister logs
62

7-
[View this sample's code on GitHub](https://github.com/dfinity/examples/tree/master/motoko/canister_logs)
8-
93
## Prerequisites
10-
This example requires an installation of:
114

12-
- [x] DFX version 0.19.0 or newer
13-
- [x] Install the [IC SDK](https://internetcomputer.org/docs/current/developer-docs/setup/install/).
14-
- [x] Download the following project files from GitHub: `git clone https://github.com/dfinity/examples/`
5+
- [x] Install the [IC
6+
SDK](https://internetcomputer.org/docs/current/developer-docs/getting-started/install). For local testing, `dfx >= 0.22.0` is required.
7+
- [x] Clone the example dapp project: `git clone https://github.com/dfinity/examples`
158

16-
You will need to have 3 terminal windows:
17-
- Terminal A: Running a DFX instance and separating its output from anything else
18-
- Terminal B: Deploying a canister and seeing its output
19-
- Terminal C: Reading logs interactively
9+
## Step 1: Setup project environment
10+
11+
Navigate into the folder containing the project's files and start a local instance of the replica with the command:
2012

21-
### Step 1: Navigate into the folder containing the project's files and start a local instance of the replica with the command:
13+
```shell
14+
dfx start --clean
15+
```
16+
17+
You will need to have 3 terminal windows:
18+
- Terminal A: Running a `dfx` instance and separating its output from anything else.
19+
- Terminal B: Deploying a canister and seeing its output.
20+
- Terminal C: Reading logs interactively.
2221

2322
```shell
2423
# Terminal A -- for running DFX and separating its output from anything else.
25-
$ cd examples/motoko/canister_logs
26-
$ dfx start --clean
24+
cd examples/motoko/canister_logs
2725

2826
# Terminal B -- for deploying the canister and calling its methods.
29-
$ cd examples/motoko/canister_logs
27+
cd examples/motoko/canister_logs
3028

3129
# Terminal C -- for polling logs.
32-
$ cd examples/motoko/canister_logs
30+
cd examples/motoko/canister_logs
3331
```
3432

35-
### Step 2: Deploy the canister:
33+
## Step 2: Deploy the canister
3634

3735
```shell
3836
# Terminal B
39-
$ dfx deploy
37+
dfx deploy
4038
```
4139

42-
### Step 3: Check canister logs:
40+
## Step 3: Check canister logs
4341

4442
Expect to see logs from timer traps.
4543

4644
```shell
4745
# Terminal B
48-
$ dfx canister logs CanisterLogs
46+
dfx canister logs CanisterLogs
4947
[0. 2024-05-23T08:32:26.203980235Z]: right before timer trap
5048
[1. 2024-05-23T08:32:26.203980235Z]: [TRAP]: timer trap
5149
[2. 2024-05-23T08:32:31.836721763Z]: right before timer trap
5250
[3. 2024-05-23T08:32:31.836721763Z]: [TRAP]: timer trap
5351
```
5452

55-
### Step 4: Call `print` method and check the logs:
53+
## Step 4: Call `print` method and check the logs
5654

5755
```shell
5856
# Terminal B
59-
$ dfx canister call CanisterLogs print hi
57+
dfx canister call CanisterLogs print hi
6058
()
6159

6260
# Expect to see new log entry.
63-
$ dfx canister logs CanisterLogs
61+
dfx canister logs CanisterLogs
6462
...
6563
[8. 2024-05-23T08:32:46.598972616Z]: right before timer trap
6664
[9. 2024-05-23T08:32:46.598972616Z]: [TRAP]: timer trap
@@ -70,7 +68,7 @@ $ dfx canister logs CanisterLogs
7068
...
7169
```
7270

73-
### Step 5: Start constantly polling logs:
71+
## Step 5: Start constantly polling logs
7472

7573
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:
7674

@@ -86,25 +84,25 @@ $ ./poll_logs.sh
8684
...
8785
```
8886

89-
### Step 6: Call `print`, `trap` and other canister methods:
87+
## Step 6: Call `print`, `trap` and other canister methods
9088

9189
```shell
9290
# Terminal B
93-
$ dfx canister call CanisterLogs print hi!
91+
dfx canister call CanisterLogs print hi!
9492
()
9593

96-
$ dfx canister call CanisterLogs print hello!
94+
dfx canister call CanisterLogs print hello!
9795
()
9896

99-
$ dfx canister call CanisterLogs print yey!
97+
dfx canister call CanisterLogs print yey!
10098
()
10199

102-
$ dfx canister call CanisterLogs trap oops!
100+
dfx canister call CanisterLogs trap oops!
103101
Error: Failed update call.
104102
Caused by: Failed update call.
105103
The replica returned a rejection error: reject code CanisterError, reject message Canister bkyz2-fmaaa-aaaaa-qaaaq-cai trapped explicitly: oops!, error code None
106104

107-
$ dfx canister call CanisterLogs memory_oob
105+
dfx canister call CanisterLogs memory_oob
108106
Error: Failed update call.
109107
Caused by: Failed update call.
110108
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

motoko/cert-var/README.md

+19-17
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
1-
---
2-
keywords: [intermediate, motoko, cert var, certified variables]
3-
---
4-
51
# Certified variables
62

7-
[View this sample's code on GitHub](https://github.com/dfinity/examples/tree/master/motoko/cert-var)
8-
9-
## Overview
103
This example demonstrates the use of a single cryptographically certified variable, as supported by the Internet Computer.
114

125
In a nutshell, this example code demonstrates "response certification" for a canister that holds a single 32-bit variable. It has two sides:
@@ -49,32 +42,39 @@ This is a Motoko example that does not currently have a Rust variant.
4942
## Prerequisites
5043
This example requires an installation of:
5144

52-
- [x] Install the [IC SDK](https://internetcomputer.org/docs/current/developer-docs/setup/install/index.mdx).
53-
- [x] Download [npm](https://nodejs.org/en/download/).
45+
## Prerequisites
46+
47+
- [x] Install the [IC
48+
SDK](https://internetcomputer.org/docs/current/developer-docs/getting-started/install). For local testing, `dfx >= 0.22.0` is required.
5449
- [x] Clone the example dapp project: `git clone https://github.com/dfinity/examples`
5550

5651
Begin by opening a terminal window.
5752

58-
### Step 1: Navigate into the folder containing the project's files and start a local instance of the Internet Computer with the command:
53+
## Step 1: Setup the project environment
54+
55+
Navigate into the folder containing the project's files and start a local instance of the Internet Computer with the commands:
56+
5957

6058
```bash
6159
cd examples/motoko/cert-var
6260
dfx start --background
6361
```
6462

65-
### Step 2: Install the front-end dependencies:
63+
## Step 2: Install the front-end dependencies
6664

6765
```bash
6866
npm install
6967
```
7068

71-
### Step 3: Deploy the canister:
69+
## Step 3: Deploy the canister
7270

7371
```bash
7472
dfx deploy
7573
```
7674

77-
### Step 4: Next, open the `webpack.config.js` file and replace the contents with the following:
75+
## Step 4: Next, open the `webpack.config.js` file.
76+
77+
Replace the contents with the following:
7878

7979
```javascript
8080
const path = require("path");
@@ -188,7 +188,9 @@ module.exports = {
188188
};
189189
```
190190

191-
### Step 5: Create a new file called `server.js` with the following content:
191+
## Step 5: Create a new file called `server.js`.
192+
193+
Add the following content:
192194

193195
```javascript
194196
var express = require('express');
@@ -203,7 +205,7 @@ app.listen(8000, function () {
203205
});
204206
```
205207

206-
### Step 6: Replace the content of the `src/cert_var_assets/src/index.html` with the following content:
208+
## Step 6: Replace the content of the `src/cert_var_assets/src/index.html` with the following:
207209

208210
```html
209211
<!doctype html>
@@ -230,14 +232,14 @@ app.listen(8000, function () {
230232
</html>
231233
```
232234

233-
### Step 7: Start a local web server that hosts the frontend.
235+
## Step 7: Start a local web server that hosts the frontend
234236

235237
```bash
236238
npm start
237239
```
238240

239241

240-
### Step 8: Visit the frontend, and interact with the demo there:
242+
## Step 8: Visit the frontend, and interact with application
241243

242244
```bash
243245
http://localhost:8080/

0 commit comments

Comments
 (0)