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
Copy file name to clipboardExpand all lines: content/md/en/docs/tutorials/smart-contracts/prepare-your-first-contract.md
+30-30Lines changed: 30 additions & 30 deletions
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ description: Build and test a simple smart contract using the ink! smart contrac
4
4
keywords:
5
5
---
6
6
7
-
As you learned in [Blockchain basics](/main-docs/learn/blockchain-basics/) decentralized applications are most often written as **smart contracts**.
7
+
As you learned in [Blockchain basics](/main-docs/learn/blockchain-basics/), decentralized applications are most often written as **smart contracts**.
8
8
9
9
Although Substrate is primarily a framework and toolkit for building custom blockchains, it can also provide a platform
10
10
for smart contracts.
@@ -17,7 +17,7 @@ In this tutorial, you'll explore using ink! as a programming language for writin
17
17
18
18
Before you begin, verify the following:
19
19
20
-
- You have good internet connection and access to a shell terminal on your local computer.
20
+
- You have a good internet connection and access to a shell terminal on your local computer.
21
21
22
22
- You are generally familiar with software development and using command-line interfaces.
23
23
@@ -35,7 +35,7 @@ By completing this tutorial, you will accomplish the following objectives:
35
35
36
36
- Deploy a smart contract on a local Substrate node.
37
37
38
-
- Interact with a smart contract using the `cargo-contract` CLI
38
+
- Interact with a smart contract using the `cargo-contract` CLI.
39
39
40
40
## Update your Rust environment
41
41
@@ -65,7 +65,7 @@ To update your development environment:
65
65
66
66
## Install `cargo-contract` CLI Tool
67
67
68
-
`cargo-contract` is a command-line tool which you will use to build, deploy, and interact with your ink! contracts.
68
+
`cargo-contract` is a command-line tool that you will use to build, deploy, and interact with your ink! contracts.
69
69
70
70
Note that in addition to Rust, installing `cargo-contract` requires a C++ compiler that supports C++17.
71
71
@@ -169,23 +169,23 @@ To explore the default project files:
169
169
170
170
1. Open a terminal shell on your computer, if needed.
171
171
172
-
1. Change to project folder for the `flipper` smart contract, if needed:
172
+
1. Change to the project folder for the `flipper` smart contract, if needed:
173
173
174
174
1. Open the `Cargo.toml` file in a text editor and review the dependencies for the contract.
175
175
176
176
1. Open the `lib.rs` file in a text editor and review the macros, constructors, and functions defined for the contract.
177
177
178
178
- The `#[ink::contract]` macro defines the entry point for your smart contract logic.
179
-
- The `#[ink(storage)` macro defines a structure to stores a single boolean value for the contract.
180
-
- The `new` and `default` functions initialize the boolean value to false.
181
-
- There's a `#[ink(message)` macro with a `flip` function to change the state of the data stored for the contract.
182
-
- There's a `#[ink(message)` macro with a `get` function to get the current state of the data stored for the contract.
179
+
- The `#[ink(storage)]` macro defines a structure to store a single Boolean value for the contract.
180
+
- The `new` and `default` functions initialize the Boolean value to false.
181
+
- There's a `#[ink(message)]` macro with a `flip` function to change the state of the data stored for the contract.
182
+
- There's a `#[ink(message)]` macro with a `get` function to get the current state of the data stored for the contract.
183
183
184
184
### Test the default contract
185
185
186
186
At the bottom of the `lib.rs` source code file, there are simple test cases to verify the functionality of the contract.
187
187
These are annotated using the `#[ink(test)]` macro. You can test whether this code is functioning as expected using the
188
-
**offchain test environment**.
188
+
**off-chain test environment**.
189
189
190
190
To test the contract:
191
191
@@ -244,7 +244,7 @@ To build the WebAssembly for this smart contract:
244
244
- flipper.json (the contract's metadata)
245
245
```
246
246
247
-
The `.contract` file includes both the business logic and metadata. This is the file that tooling (e.g UIs) expect
247
+
The `.contract` file includes both the business logic and metadata. This is the file that tooling (e.g. UIs) expects
248
248
when you want to deploy your contract on-chain.
249
249
250
250
The `.json` file describes all the interfaces that you can use to interact with this contract. This file
@@ -261,7 +261,7 @@ To build the WebAssembly for this smart contract:
261
261
262
262
## Start the Substrate Contracts Node
263
263
264
-
If you have [successfully installed the `substrate-contracts-node`](/tutorials/smart-contracts/prepare-your-first-contract/#install-the-substrate-contracts-node),
264
+
If you have [successfully installed the `substrate-contracts-node`](/tutorials/smart-contracts/prepare-your-first-contract/#install-the-substrate-contracts-node),
265
265
it's time to start a local node.
266
266
267
267
1. Start the contracts node in local development mode by running the following command:
@@ -351,17 +351,17 @@ Substrate chain.
351
351
Some notes about the command:
352
352
- The `instantiate` command will do both the `upload` and `instantiate` steps for you.
353
353
354
-
-We need to specify the contract constructor to use, which in this case is `new()`
354
+
-You need to specify the contract constructor to use, which in this case is `new()`.
355
355
356
-
-We need to specify the argument to the constructor, which in this case is `false`
356
+
-You need to specify the argument to the constructor, which in this case is `false`.
357
357
358
-
-We need to specify the account uploading and instantiating the contract, which in this case is the default
359
-
development account of `//Alice`
358
+
-You need to specify the account uploading and instantiating the contract, which in this case is the default
359
+
development account of `//Alice`.
360
360
361
-
- During development we may want to upload the instantiate the same contract multiple times, so we specify a `salt`
361
+
- During development, you may want to upload and instantiate the same contract multiple times, so you specify a `salt`
362
362
using the current time. Note that this is optional.
363
363
364
-
After running the command confirming that we're happy with the gas estimatation we should see something like this:
364
+
After running the command and confirming that you're happy with the gas estimation, you should see something like this:
365
365
366
366
```text
367
367
Dry-running new (skip with --skip-dry-run)
@@ -397,29 +397,29 @@ We can not only `upload` and `instantiate` contracts using `cargo-contract`, we
397
397
398
398
### `get()` Message
399
399
400
-
When we initialized the contract we set the initial value of the `flipper` to `false`. We can confirm this by calling
400
+
When we initialized the contract, we set the initial value of the `flipper` to `false`. We can confirm this by calling
401
401
the `get()` message.
402
402
403
-
Since we are only reading from the blockchain state (we're not writing any new data) we can use the `--dry-run` flag to
403
+
Since we are only reading from the blockchain state (we're not writing any new data), we can use the `--dry-run` flag to
404
404
avoid submitting an extrinsic.
405
405
406
406
```bash
407
407
cargo contract call --contract $INSTANTIATED_CONTRACT_ADDRESS --message get --suri //Alice --dry-run
408
408
```
409
409
410
410
Some notes about the command:
411
-
- The address of the contract we want to call had to be specified using the `--contract` flag
411
+
- The address of the contract we want to call had to be specified using the `--contract` flag.
412
412
413
-
- This can be found in the output logs of the `cargo contract instantiate` command
413
+
- This address can be found in the output logs of the `cargo contract instantiate` command.
414
414
415
-
- We need to specify the contract message to use, which in this case is `get()`
415
+
- We need to specify the contract message to use, which in this case is `get()`.
416
416
417
-
- We need to specify the account callling the contract, which in this case is the default development account of
418
-
`//Alice`
417
+
- We need to specify the account calling the contract, which in this case is the default development account of
418
+
`//Alice`.
419
419
420
-
- We specify `--dry-run` to avoid submitting an extrinsic on-chain
420
+
- We specify `--dry-run` to avoid submitting an extrinsic on-chain.
421
421
422
-
After running the command should see something like this:
422
+
After running the command, you should see something like this:
423
423
424
424
```text
425
425
Result Success!
@@ -433,18 +433,18 @@ We're interested in the `value` here, which is `false` as expected.
433
433
434
434
The `flip()` message changes the storage value from `false` to `true` and vice versa.
435
435
436
-
To call the `flip()` message we will need to submit an extrinsic on-chain because we are altering the state of the
436
+
To call the `flip()` message, we will need to submit an extrinsic on-chain because we are altering the state of the
0 commit comments