Skip to content

Commit 59b4cff

Browse files
Merge pull request #1070 from dfinity/update-motoko-readmes
Update Motoko project READMEs
2 parents 0c50a6c + c0ff17e commit 59b4cff

File tree

30 files changed

+469
-700
lines changed

30 files changed

+469
-700
lines changed

archive/motoko/dip721-nft-container/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Using this management canister address, we can construct its principal and set t
8888

8989
## NFT sample code tutorial
9090

91-
### Prerequisites
91+
## Prerequisites
9292

9393
- [x] Install the [IC SDK](https://internetcomputer.org/docs/current/developer-docs/setup/install/index.mdx).
9494
- [x] Download and install [git.](https://git-scm.com/downloads)

archive/motoko/hello/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ This example demonstrates a dead simple dapp consisting of two canister smart co
4141

4242
This example is based on the default project created by running `dfx new hello`.
4343

44-
### Prerequisites
44+
## Prerequisites
4545
This example requires an installation of:
4646
- [x] Install the [IC SDK](https://internetcomputer.org/docs/current/developer-docs/setup/install/index.mdx).
4747
- [x] Install `node.js` (to build the web frontend).

archive/motoko/persistent-storage/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ This example covers:
2424
## Installation
2525
This example project can be cloned, installed, and deployed locally, for learning and testing purposes. The instructions are based on running the example on either macOS or Linux, but when using WSL2 on Windows, the instructions will be the same.
2626

27-
### Prerequisites
27+
## Prerequisites
2828
This example requires an installation of:
2929

3030
- [x] Install the [IC SDK](https://internetcomputer.org/docs/current/developer-docs/setup/install/index.mdx).
@@ -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

Lines changed: 10 additions & 16 deletions
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

Lines changed: 12 additions & 15 deletions
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

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,43 @@
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

@@ -52,7 +50,7 @@ $ dfx canister logs CanisterLogs
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
@@ -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,7 +84,7 @@ $ ./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

motoko/cert-var/README.md

Lines changed: 19 additions & 17 deletions
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 the application
241243

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

motoko/classes/README.md

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
1-
---
2-
keywords: [beginner, motoko, classes, actor classes]
3-
---
4-
51
# Classes
62

7-
[View this sample's code on GitHub](https://github.com/dfinity/examples/tree/master/motoko/classes)
8-
9-
## Overview
10-
113
This example demonstrates a simple use of actor classes, allowing a program to dynamically install new actors (that is, canisters). It also demonstrates a multi-canister project, and actors using inter-actor communication through shared functions.
124

135
The example defines two Motoko actors, `Map` and `Test`.
@@ -26,29 +18,32 @@ The `Test.mo` actor imports the (installed) `Map` canister, using `Maps` Candid
2618

2719
This is a Motoko example that does not currently have a Rust variant.
2820

29-
3021
## Prerequisites
31-
This example requires an installation of:
3222

33-
- [x] Install the [IC SDK](https://internetcomputer.org/docs/current/developer-docs/setup/install/).
23+
- [x] Install the [IC
24+
SDK](https://internetcomputer.org/docs/current/developer-docs/getting-started/install). For local testing, `dfx >= 0.22.0` is required.
3425
- [x] Clone the example dapp project: `git clone https://github.com/dfinity/examples`
3526

3627
Begin by opening a terminal window.
3728

38-
### Step 1: Navigate into the folder containing the project's files and start a local instance of the Internet Computer with the command:
29+
## Step 1: Setup the project environment
30+
31+
Navigate into the folder containing the project's files and start a local instance of the Internet Computer with the commands:
32+
3933

4034
```bash
4135
cd examples/motoko/classes
4236
dfx start --background
4337
```
4438

45-
### Step 2: Deploy the canisters `Map` and `Test`:
39+
## Step 2: Deploy the canisters `Map` and `Test`
4640

4741
```bash
48-
dfx deploy
42+
dfx deploy Map
43+
dfx deploy Test
4944
```
5045

51-
### Step 3: Invoke the run method of canister Test:
46+
## Step 3: Invoke the run method of canister `Test`
5247

5348
```bash
5449
dfx canister call Test run '()'

0 commit comments

Comments
 (0)