Skip to content
This repository was archived by the owner on Aug 20, 2020. It is now read-only.

Commit b5c6993

Browse files
committed
Update Add a Pallet
1 parent b448b2e commit b5c6993

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

tuts/add-a-pallet/v2.0.0-rc2/index.md

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ blockchain. However, in the attempts to remain minimal, it does not include most
1010
([FRAME](/kb/runtime/frame)).
1111

1212
This guide will show you how you can add the
13-
[Contracts pallet](https://docs.rs/crate/pallet-contracts/2.0.0-alpha.8) to your runtime in order to
13+
[Contracts pallet](https://docs.rs/crate/pallet-contracts/2.0.0-rc2) to your runtime in order to
1414
allow your blockchain to support Wasm smart contracts. You can follow similar patterns to add
1515
additional FRAME pallets to your runtime, however you should note that each pallet is a little
1616
different in terms of the specific configuration settings needed to use it correctly.
1717

1818
## Install the Node Template
1919

20-
You should already have version `v2.0.0-alpha.8` of the
20+
You should already have version `v2.0.0-rc2` of the
2121
[Substrate Node Template](https://github.com/substrate-developer-hub/substrate-node-template)
2222
compiled on your computer from when you completed the
23-
[Create Your First Substrate Chain Tutorial](/tutorials/create-your-first-substrate-chain/v2.0.0-alpha.8).
23+
[Create Your First Substrate Chain Tutorial](/tutorials/create-your-first-substrate-chain/v2.0.0-rc2).
2424
If you do not, please complete that tutorial.
2525

2626
> Experienced developers who truly prefer to skip that tutorial, you may install the node template
@@ -63,16 +63,17 @@ check out [their official documentation](https://doc.rust-lang.org/cargo/referen
6363

6464
Open `substrate-node-template/runtime/Cargo.toml` and you will see a list of all the dependencies
6565
your runtime has. For example, it depends on the
66-
[Balances pallet](https://docs.rs/crate/pallet-balances/2.0.0-alpha.8):
66+
[Balances pallet](https://docs.rs/crate/pallet-balances/2.0.0-rc2):
6767

6868
**`runtime/Cargo.toml`**
6969

7070
```TOML
7171
[dependencies.balances]
72-
git = 'https://github.com/paritytech/substrate.git'
7372
default-features = false
73+
git = 'https://github.com/paritytech/substrate.git'
7474
package = 'pallet-balances'
75-
tag = 'v2.0.0-alpha.8'
75+
tag = 'v2.0.0-rc2'
76+
version = '2.0.0-rc2'
7677
```
7778

7879
### Crate Features
@@ -150,13 +151,13 @@ So based on the `balances` import shown above, the `contracts` import will look
150151
git = 'https://github.com/paritytech/substrate.git'
151152
default-features = false
152153
package = 'pallet-contracts'
153-
tag = 'v2.0.0-alpha.8'
154+
tag = 'v2.0.0-rc2'
154155

155156
[dependencies.contracts-primitives]
156157
git = 'https://github.com/paritytech/substrate.git'
157158
default-features = false
158159
package = 'pallet-contracts-primitives'
159-
tag = 'v2.0.0-alpha.8'
160+
tag = 'v2.0.0-rc2'
160161
```
161162

162163
As with other pallets, the Contracts pallet has an `std` feature. We should build its `std` feature
@@ -221,7 +222,7 @@ Every pallet has a configuration trait called `Trait` that the runtime must impl
221222

222223
To figure out what we need to implement for this pallet specifically, you can take a look to the
223224
FRAME
224-
[`contracts::Trait` documentation](https://docs.rs/pallet-contracts/2.0.0-alpha.8/pallet_contracts/trait.Trait.html).
225+
[`contracts::Trait` documentation](https://substrate.dev/rustdocs/v2.0.0-rc2/pallet_contracts/trait.Trait.html).
225226
For our runtime, the implementation will look like this:
226227

227228
**`runtime/src/lib.rs`**
@@ -275,19 +276,19 @@ impl contracts::Trait for Runtime {
275276

276277
We will use `type DetermineContractAddress` as an example to go into a bit more detail - you can see
277278
from
278-
[the `DetermineContractAddress` documentation](https://docs.rs/pallet-contracts/2.0.0-alpha.8/pallet_contracts/trait.Trait.html#associatedtype.DetermineContractAddress)
279+
[the `DetermineContractAddress` documentation](https://substrate.dev/rustdocs/v2.0.0-rc2/pallet_contracts/trait.Trait.html#associatedtype.DetermineContractAddress)
279280
that it requires the trait `ContractAddressFor`. The Contracts pallet itself implements a type with
280281
this trait in `contract::SimpleAddressDeterminator`, thus we can use that implementation to satisfy
281282
our `contracts::Trait`. At this point, I really recommend you explore the source code of the
282-
[Contracts pallet](https://github.com/paritytech/substrate/blob/v2.0.0-alpha.8/frame/contracts/src/lib.rs)
283+
[Contracts pallet](https://github.com/paritytech/substrate/blob/v2.0.0-rc2/frame/contracts/src/lib.rs)
283284
if things don't make sense or you want to gain a deeper understanding.
284285

285286
### Adding Contracts to the `construct_runtime!` Macro
286287

287288
Next, we need to add the pallet to the `construct_runtime!` macro. For this, we need to determine
288289
the types that the pallet exposes so that we can tell the our runtime that they exist. The complete
289290
list of possible types can be found in the
290-
[`construct_runtime!` macro documentation](https://docs.rs/frame-support/2.0.0-alpha.8/frame_support/macro.construct_runtime.html).
291+
[`construct_runtime!` macro documentation](https://substrate.dev/rustdocs/v2.0.0-rc2/frame_support/macro.construct_runtime.html).
291292

292293
If we look at the Contracts pallet in detail, we know it has:
293294

@@ -345,8 +346,8 @@ We start by adding the required API dependencies in our `Cargo.toml`.
345346
git = 'https://github.com/paritytech/substrate.git'
346347
default-features = false
347348
package = 'pallet-contracts-rpc-runtime-api'
348-
version = '0.8.0-alpha.8'
349-
tag = 'v2.0.0-alpha.8'
349+
version = '0.8.0-rc2'
350+
tag = 'v2.0.0-rc2'
350351
```
351352

352353
**`runtime/Cargo.toml`**
@@ -446,12 +447,12 @@ jsonrpc-core = '14.0.5'
446447

447448
[dependencies.pallet-contracts-rpc]
448449
git = 'https://github.com/paritytech/substrate.git'
449-
version = '0.8.0-alpha.8'
450-
tag = 'v2.0.0-alpha.8'
450+
version = '0.8.0-rc2'
451+
tag = 'v2.0.0-rc2'
451452

452453
[dependencies.sc-rpc]
453454
git = 'https://github.com/paritytech/substrate.git'
454-
tag = 'v2.0.0-alpha.8'
455+
tag = 'v2.0.0-rc2'
455456
```
456457

457458
**`node/src/service.rs`**
@@ -489,7 +490,7 @@ add the contracts pallet along with its API.
489490

490491
Not all pallets will have a genesis configuration, but if yours does, you can use its documentation
491492
to learn about it. For example,
492-
[`pallet_contracts::GenesisConfig` documentation](https://docs.rs/pallet-contracts/2.0.0-alpha.8/pallet_contracts/struct.GenesisConfig.html)
493+
[`pallet_contracts::GenesisConfig` documentation](https://substrate.dev/rustdocs/v2.0.0-rc2/pallet_contracts/struct.GenesisConfig.html)
493494
describes all the fields you need to define for the Contracts pallet.
494495

495496
Genesis configurations are controlled in `node/src/chain_spec.rs`. We need to modify this file to
@@ -551,7 +552,7 @@ without purging it but it will remain out of scope for this tutorial.
551552
In this guide, we walked through specifically how to import the Contracts pallet, but as mentioned
552553
in the beginning of this guide, each pallet will be a little different. Have no fear, you can always
553554
refer to the
554-
[demonstration Substrate node runtime](https://github.com/paritytech/substrate/blob/v2.0.0-alpha.8/bin/node/runtime/)
555+
[demonstration Substrate node runtime](https://github.com/paritytech/substrate/blob/v2.0.0-rc2/bin/node/runtime/)
555556
which includes nearly every pallet in the FRAME.
556557

557558
In the `Cargo.toml` file of the Substrate node runtime, you will see an example of how to import
@@ -560,7 +561,7 @@ runtime. You can basically copy what was done there to your own runtime.
560561

561562
### Learn More
562563

563-
- [A minimalist tutorial on writing your runtime pallet in its own package](/tutorials/pallet-in-own-crate/v2.0.0-alpha.8).
564+
- [A minimalist tutorial on writing your runtime pallet in its own package](/tutorials/pallet-in-own-crate/v2.0.0-rc2).
564565
- With your node now capable of running smart contracts, go learn about
565566
[Substrate ink! smart contracts](/kb/smart-contracts).
566567
- [Substrate Recipes](https://substrate.dev/recipes/) offers detailed tutorials about writing
@@ -572,4 +573,4 @@ runtime. You can basically copy what was done there to your own runtime.
572573

573574
### References
574575

575-
- [FRAME `Contracts` Pallet API](https://docs.rs/pallet-contracts/2.0.0-alpha.8/pallet_contracts/index.html)
576+
- [FRAME `Contracts` Pallet API](https://substrate.dev/rustdocs/v2.0.0-rc2/pallet_contracts/index.html)

0 commit comments

Comments
 (0)