@@ -10,17 +10,17 @@ blockchain. However, in the attempts to remain minimal, it does not include most
10
10
([ FRAME] ( /kb/runtime/frame ) ).
11
11
12
12
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
14
14
allow your blockchain to support Wasm smart contracts. You can follow similar patterns to add
15
15
additional FRAME pallets to your runtime, however you should note that each pallet is a little
16
16
different in terms of the specific configuration settings needed to use it correctly.
17
17
18
18
## Install the Node Template
19
19
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
21
21
[ Substrate Node Template] ( https://github.com/substrate-developer-hub/substrate-node-template )
22
22
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 ) .
24
24
If you do not, please complete that tutorial.
25
25
26
26
> 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
63
63
64
64
Open ` substrate-node-template/runtime/Cargo.toml ` and you will see a list of all the dependencies
65
65
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 ) :
67
67
68
68
** ` runtime/Cargo.toml ` **
69
69
70
70
``` TOML
71
71
[dependencies .balances ]
72
- git = ' https://github.com/paritytech/substrate.git'
73
72
default-features = false
73
+ git = ' https://github.com/paritytech/substrate.git'
74
74
package = ' pallet-balances'
75
- tag = ' v2.0.0-alpha.8'
75
+ tag = ' v2.0.0-rc2'
76
+ version = ' 2.0.0-rc2'
76
77
```
77
78
78
79
### Crate Features
@@ -150,13 +151,13 @@ So based on the `balances` import shown above, the `contracts` import will look
150
151
git = ' https://github.com/paritytech/substrate.git'
151
152
default-features = false
152
153
package = ' pallet-contracts'
153
- tag = ' v2.0.0-alpha.8 '
154
+ tag = ' v2.0.0-rc2 '
154
155
155
156
[dependencies .contracts-primitives ]
156
157
git = ' https://github.com/paritytech/substrate.git'
157
158
default-features = false
158
159
package = ' pallet-contracts-primitives'
159
- tag = ' v2.0.0-alpha.8 '
160
+ tag = ' v2.0.0-rc2 '
160
161
```
161
162
162
163
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
221
222
222
223
To figure out what we need to implement for this pallet specifically, you can take a look to the
223
224
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 ) .
225
226
For our runtime, the implementation will look like this:
226
227
227
228
** ` runtime/src/lib.rs ` **
@@ -275,19 +276,19 @@ impl contracts::Trait for Runtime {
275
276
276
277
We will use ` type DetermineContractAddress ` as an example to go into a bit more detail - you can see
277
278
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 )
279
280
that it requires the trait ` ContractAddressFor ` . The Contracts pallet itself implements a type with
280
281
this trait in ` contract::SimpleAddressDeterminator ` , thus we can use that implementation to satisfy
281
282
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 )
283
284
if things don't make sense or you want to gain a deeper understanding.
284
285
285
286
### Adding Contracts to the ` construct_runtime! ` Macro
286
287
287
288
Next, we need to add the pallet to the ` construct_runtime! ` macro. For this, we need to determine
288
289
the types that the pallet exposes so that we can tell the our runtime that they exist. The complete
289
290
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 ) .
291
292
292
293
If we look at the Contracts pallet in detail, we know it has:
293
294
@@ -345,8 +346,8 @@ We start by adding the required API dependencies in our `Cargo.toml`.
345
346
git = ' https://github.com/paritytech/substrate.git'
346
347
default-features = false
347
348
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 '
350
351
```
351
352
352
353
** ` runtime/Cargo.toml ` **
@@ -446,12 +447,12 @@ jsonrpc-core = '14.0.5'
446
447
447
448
[dependencies .pallet-contracts-rpc ]
448
449
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 '
451
452
452
453
[dependencies .sc-rpc ]
453
454
git = ' https://github.com/paritytech/substrate.git'
454
- tag = ' v2.0.0-alpha.8 '
455
+ tag = ' v2.0.0-rc2 '
455
456
```
456
457
457
458
** ` node/src/service.rs ` **
@@ -489,7 +490,7 @@ add the contracts pallet along with its API.
489
490
490
491
Not all pallets will have a genesis configuration, but if yours does, you can use its documentation
491
492
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 )
493
494
describes all the fields you need to define for the Contracts pallet.
494
495
495
496
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.
551
552
In this guide, we walked through specifically how to import the Contracts pallet, but as mentioned
552
553
in the beginning of this guide, each pallet will be a little different. Have no fear, you can always
553
554
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/ )
555
556
which includes nearly every pallet in the FRAME.
556
557
557
558
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.
560
561
561
562
### Learn More
562
563
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 ) .
564
565
- With your node now capable of running smart contracts, go learn about
565
566
[ Substrate ink! smart contracts] ( /kb/smart-contracts ) .
566
567
- [ 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.
572
573
573
574
### References
574
575
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