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
@@ -953,7 +953,7 @@ so the correct method is to use the transaction's event proper.
953
953
CosmWasm has kept some information about your new instance. At any time, you can retrieve it with:
954
954
955
955
<Tabs groupId="local-docker">
956
-
<TabItem value="Local" active>
956
+
<TabItem value="Local" default>
957
957
```shell
958
958
./build/wasmd query wasm contract $ns_addr1
959
959
```
@@ -990,7 +990,7 @@ contract_info:
990
990
At a later stage, your contract instances may hold a token balance. At any time, you can fetch this information with:
991
991
992
992
<Tabs groupId="local-docker">
993
-
<TabItem value="Local" active>
993
+
<TabItem value="Local" default>
994
994
```shell
995
995
./build/wasmd query bank balances $ns_addr1
996
996
```
@@ -1022,7 +1022,7 @@ The instance keeps its state in storage. If you come from Ethereum, you are fami
1022
1022
The equivalent command in CosmWasm is `query wasm contract-state`. Conveniently, it also has the `all` subcommand. So let's see what the instance has in storage with:
1023
1023
1024
1024
<Tabs groupId="local-docker">
1025
-
<TabItem value="Local" active>
1025
+
<TabItem value="Local" default>
1026
1026
```shell
1027
1027
./build/wasmd query wasm contract-state all $ns_addr1
1028
1028
```
@@ -1100,7 +1100,7 @@ Now that you know that:
1100
1100
You can query the instance's state directly, without the `all` keyword. Either with the key in ASCII:
1101
1101
1102
1102
<Tabs groupId="local-docker">
1103
-
<TabItem value="Local" active>
1103
+
<TabItem value="Local" default>
1104
1104
```shell
1105
1105
./build/wasmd query wasm contract-state raw $ns_addr1 \
1106
1106
name_minter --ascii \
@@ -1124,7 +1124,7 @@ You can query the instance's state directly, without the `all` keyword. Either w
1124
1124
Or with the key in hex:
1125
1125
1126
1126
<Tabs groupId="local-docker">
1127
-
<TabItem value="Local" active>
1127
+
<TabItem value="Local" default>
1128
1128
```shell
1129
1129
./build/wasmd query wasm contract-state raw $ns_addr1 \
1130
1130
6E616D655F6D696E746572 --hex \
@@ -1219,7 +1219,7 @@ Press _Encode_ and on the right you see `wasm14hj2tavq8fpesdwxxcu44rty3hh90vhujr
@@ -1397,7 +1397,7 @@ There comes a long list of events. Note this particular one:
1397
1397
It is emitted by the bank module and is the trace that tells you that Alice paid the name service contract `100stake`. And indeed, you can confirm that now the smart contract instance holds tokens:
Copy file name to clipboardExpand all lines: docs/tutorial/platform/05-first-contract.md
+21-21Lines changed: 21 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,7 @@ It was built with Rust 1.80.1 for CosmWasm 2.1.3. It may work with other version
25
25
Most likely, you will start your CosmWasm project as a Rust project. Use `cargo` to initialize a new one.
26
26
27
27
<TabsgroupId="local-docker">
28
-
<TabItem value="Local" active>
28
+
<TabItem value="Local" default>
29
29
```shell
30
30
cargo new my-nameservice --lib --edition 2021
31
31
```
@@ -68,9 +68,9 @@ pub struct InstantiateMsg {}
68
68
You use the attribute macro [`cw_serde`](https://docs.cosmwasm.com/core/entrypoints#defining-your-own-messages) in order to make your for-now-empty _instantiate_ message serializable. Make its content available to the Rust project by replacing the sample code in `src/lib.rs` with:
69
69
70
70
```rust title="src/lib.rs"
71
-
//with-coverage
71
+
//diff-add
72
72
+pubmodmsg;
73
-
//no-coverage-start
73
+
//diff-del-start
74
74
-pubfnadd(left:u64, right:u64) ->u64 {
75
75
-left+right
76
76
- }
@@ -79,15 +79,15 @@ You use the attribute macro [`cw_serde`](https://docs.cosmwasm.com/core/entrypoi
79
79
-modtests {
80
80
-...
81
81
- }
82
-
//no-coverage-end
82
+
//diff-del-end
83
83
```
84
84
85
85
Note that it says `pub` as the message needs to be known outside of the project, including tests.
86
86
87
87
Back in `src/msg.rs` you will notice that `cosmwasm_schema` now appears as an `unresolved import`. You see the same message if you try to build:
@@ -288,7 +288,7 @@ At this stage, you should have something similar to the [`improve-error-reportin
288
288
You can already build with the `cargo build` command. How about building to WebAssembly? You need to add the WebAssembly compiling target for that, if it was not yet installed.
289
289
290
290
<TabsgroupId="local-docker">
291
-
<TabItem value="Local" active>
291
+
<TabItem value="Local" default>
292
292
```shell
293
293
rustup target add wasm32-unknown-unknown
294
294
```
@@ -315,7 +315,7 @@ You can already build with the `cargo build` command. How about building to WebA
315
315
With the target installed, you can compile to WebAssembly with:
With this alias defined, you can now use `cargo wasm` instead of writing `cargo build --release --target wasm32-unknown-unknown`. Change your command to:
348
348
349
349
<TabsgroupId="local-docker">
350
-
<TabItem value="Local" active>
350
+
<TabItem value="Local" default>
351
351
```shell
352
352
cargo wasm
353
353
```
@@ -372,7 +372,7 @@ name = "my-nameservice"
372
372
version = "0.1.0"
373
373
edition = "2021"
374
374
375
-
//with-coverage-start
375
+
//diff-add-start
376
376
+ # Linkage options. More information: https://doc.rust-lang.org/reference/linkage.html
377
377
+ [lib]
378
378
+ crate-type = ["cdylib", "rlib"]
@@ -392,7 +392,7 @@ edition = "2021"
392
392
+ panic = 'abort'
393
393
+ incremental = false
394
394
+ overflow-checks = true
395
-
//with-coverage-end
395
+
//diff-add-end
396
396
397
397
[dependencies]
398
398
...
@@ -453,7 +453,7 @@ Note how:
453
453
With the test ready, you can run it with the following command:
0 commit comments