Skip to content

Commit 80ea550

Browse files
update rust readmes
1 parent 786c2e9 commit 80ea550

File tree

20 files changed

+301
-481
lines changed

20 files changed

+301
-481
lines changed

motoko/canister_logs/README.md

+26-28
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,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

rust/basic_bitcoin/README.md

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

7-
[View this sample's code on GitHub](https://github.com/dfinity/examples/tree/master/rust/basic_bitcoin)
8-
9-
## Overview
103
This tutorial will walk you through how to deploy a sample [canister smart contract](https://internetcomputer.org/docs/current/developer-docs/multi-chain/bitcoin/overview) **that can send and receive Bitcoin** on the Internet Computer.
114

125
## Architecture
@@ -21,18 +14,16 @@ of the Internet Computer.
2114

2215
For a deeper understanding of the ICP < > BTC integration, see the [Bitcoin integration documentation](https://wiki.internetcomputer.org/wiki/Bitcoin_Integration).
2316

24-
## Prerequisites
17+
### Prerequisites
2518

2619
* [x] Install the [IC
27-
SDK](https://internetcomputer.org/docs/current/developer-docs/setup/install/index.mdx).
20+
SDK](https://internetcomputer.org/docs/current/developer-docs/getting-started/install).
2821
For local testing, `dfx >= 0.22.0-beta.0` is required.
2922
* [x] On macOS, `llvm` with the `wasm32-unknown-unknown` target (which is not included in the XCode installation by default) is required.
3023
To install, run `brew install llvm`.
3124

3225
## Step 1: Building and deploying sample code
3326

34-
### Clone the smart contract
35-
3627
This tutorial has the same smart contract written in
3728
[Motoko](https://internetcomputer.org/docs/current/developer-docs/backend/motoko/index.md)
3829
using ECDSA, Schnorr, and Bitcoin API.
@@ -130,7 +121,7 @@ from three types of addresses:
130121
Note that P2TR *key path* spending with a tweaked key is currently not available
131122
on the IC because the threshold Schnorr signing interface does not allow
132123
applying BIP341 tweaks to the private key. In contrast, the
133-
tweaked public key is used to spend in the script path, which is availble on the
124+
tweaked public key is used to spend in the script path, which is available on the
134125
IC. For a technical comparison of different ways of how single-signer P2TR
135126
addresses can be constructed and used, you may want to take a look at [this
136127
post](https://bitcoin.stackexchange.com/a/111100) by Pieter Wuille.

rust/basic_dao/README.md

+19-23
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
1-
---
2-
keywords: [advanced, rust, 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/rust/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`.
@@ -18,37 +10,39 @@ Certain system parameters, like the number of `Yes` votes needed to pass a propo
1810

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

21-
## Prerequisites
13+
### Prerequisites
2214
This example requires an installation of:
2315

2416
- [x] The Rust toolchain (e.g. cargo).
2517
- [x] [didc.](https://github.com/dfinity/candid/tree/master/tools/didc)
26-
- [x] Install the [IC SDK](https://internetcomputer.org/docs/current/developer-docs/setup/install/).
18+
- [x] Install the [IC SDK](https://internetcomputer.org/docs/current/developer-docs/getting-started/install).
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: Build the `basic_dao` canister:
23+
## Step 1: Build the `basic_dao` canister
3224

3325
```bash
3426
make clean; make
3527
```
3628

37-
### Step 2: Navigate into the folder containing the project's files and start a local instance of the Internet Computer with the command:
29+
## Step 2: Setup the dev environment
30+
31+
Navigate into the folder containing the project's files and start a local instance of the Internet Computer with the command:
3832

3933
```bash
4034
cd basic_dao
4135
dfx start --background
4236
```
4337

44-
### Step 3: Create test identities with the commands:
38+
## Step 3: Create test identities with the commands
4539

4640
```bash
4741
dfx identity new --disable-encryption Alice; dfx identity use Alice; export ALICE=$(dfx identity get-principal);
4842
dfx identity new --disable-encryption Bob; dfx identity use Bob; export BOB=$(dfx identity get-principal);
4943
```
5044

51-
### Step 4: Deploy basic_dao with the initial test accounts:
45+
## Step 4: Deploy basic_dao with the initial test accounts
5246

5347
```bash
5448
dfx deploy --argument "(record {
@@ -63,7 +57,7 @@ dfx deploy --argument "(record {
6357
})"
6458
```
6559

66-
### Step 5: List accounts and confirm you see the two test accounts:
60+
## Step 5: List accounts and confirm you see the two test accounts
6761

6862
```bash
6963
dfx canister call basic_dao list_accounts '()'
@@ -86,7 +80,7 @@ Output:
8680
)
8781
```
8882
89-
### Step 6: Call `account_balance` as Bob:
83+
## Step 6: Call `account_balance` as Bob
9084
9185
```bash
9286
dfx canister call basic_dao account_balance '()'
@@ -98,7 +92,7 @@ You should see the output:
9892
(record { amount_e8s = 100_000_000 : nat64 })
9993
```
10094
101-
### Step 7: Transfer tokens to Alice:
95+
## Step 7: Transfer tokens to Alice
10296
10397
```bash
10498
dfx canister call basic_dao transfer "(record { to = principal \"$ALICE\"; amount = record { amount_e8s = 90_000_000:nat;};})";
@@ -110,7 +104,7 @@ Output:
110104
(variant { Ok })
111105
```
112106
113-
### Step 8: List accounts and see that the transfer was made:
107+
## Step 8: List accounts and see that the transfer was made
114108
115109
```bash
116110
dfx canister call basic_dao list_accounts '()'
@@ -137,7 +131,9 @@ Output:
137131
Note that the transfer fee was deducted from Bob's account.
138132
:::
139133
140-
### Step 9: Let's make a proposal to change the transfer fee. You can call `get_system_params` to learn the current transfer fee:
134+
## Step 9: Let's make a proposal to change the transfer fee
135+
136+
You can call `get_system_params` to learn the current transfer fee:
141137
142138
```bash
143139
dfx canister call basic_dao get_system_params '()';
@@ -177,7 +173,7 @@ Output:
177173
blob "DIDL\03l\01\f2\c7\94\ae\03\01n\02l\01\b9\ef\93\80\08x\01\00\01 N\00\00\00\00\00\00"
178174
```
179175
180-
### Step 10: We can then submit the proposal:
176+
## Step 10: We can then submit the proposal
181177
182178
```bash
183179
dfx canister call basic_dao submit_proposal '(record { canister_id = principal "rrkah-fqaaa-aaaaa-aaaaq-cai";
@@ -191,15 +187,15 @@ Note the output proposal ID:
191187
(variant { Ok = 0 : nat64 })
192188
```
193189
194-
### Step 11: Confirm the proposal was created:
190+
## Step 11: Confirm the proposal was created
195191
196192
```bash
197193
dfx canister call basic_dao get_proposal '(0:nat64)'
198194
```
199195
200196
You should see `state = variant { Open };` in the output.
201197
202-
### Step 12: Vote on the proposal:
198+
## Step 12: Vote on the proposal
203199
204200
```bash
205201
dfx canister call basic_dao vote '(record { proposal_id = 0:nat64; vote = variant { Yes };})'
@@ -253,7 +249,7 @@ Output:
253249
)
254250
```
255251
256-
### Resources
252+
## Resources
257253
- [ic-cdk](https://docs.rs/ic-cdk/latest/ic_cdk/)
258254
- [ic-cdk-macros](https://docs.rs/ic-cdk-macros)
259255
- [JavaScript API reference](https://erxue-5aaaa-aaaab-qaagq-cai.ic0.app/)

rust/basic_ethereum/README.md

+2-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
1-
---
2-
keywords: [ advanced, rust, ethereum, eth, integration, ethereum integration ]
3-
---
4-
51
# Basic Ethereum
62

7-
[View this sample's code on GitHub](https://github.com/dfinity/examples/tree/master/rust/basic_ethereum)
8-
9-
## Overview
10-
113
This tutorial will walk you through how to deploy a
124
sample [canister smart contract](https://internetcomputer.org/docs/current/developer-docs/multi-chain/ethereum/overview)
135
**that can send and receive Ether (ETH)** on the Internet Computer.
@@ -22,9 +14,9 @@ features of the Internet Computer.
2214
For a deeper understanding of the ICP < > ETH integration, see
2315
the [Ethereum integration overview](https://internetcomputer.org/docs/current/developer-docs/multi-chain/ethereum/overview).
2416

25-
## Prerequisites
17+
### Prerequisites
2618

27-
* [x] Install the [IC SDK](https://internetcomputer.org/docs/current/developer-docs/setup/install/index.mdx).
19+
- [x] Install the [IC SDK](https://internetcomputer.org/docs/current/developer-docs/getting-started/install).
2820

2921
## Step 1: Building and deploying sample code
3022

rust/canister-info/README.md

-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
1-
---
2-
keywords: [beginner, rust, canister info]
3-
---
4-
51
# Canister info
62

7-
[View this sample's code on GitHub](https://github.com/dfinity/examples/tree/master/rust/canister-info)
8-
93
The purpose of this dapp is to give developers a small (backend) dapp that uses the IC's `canister_info` management call to retrieve information about canisters including canister history.
104

115
You can find a detailed description of its methods in the form of doc comments in the source code.

0 commit comments

Comments
 (0)