Skip to content

Commit

Permalink
updates to interaction slide
Browse files Browse the repository at this point in the history
  • Loading branch information
Ank4n committed Jan 16, 2024
1 parent e5ee3fa commit 354764d
Showing 1 changed file with 36 additions and 45 deletions.
81 changes: 36 additions & 45 deletions syllabus/5-Substrate/9-Substrate-Interactions_Slides.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ duration: 60 minutes
## Before we start

Find all the commands that will be used in this workshop:
[hackmd.io/@ak0n/hk24-substrate-interaction](https://hackmd.io/@ak0n/hk24-substrate-interaction)
[tinyurl.com/hk24-substrate](https://hackmd.io/@ak0n/hk24-substrate-interaction)

---

Expand Down Expand Up @@ -142,7 +142,7 @@ https://paritytech.github.io/substrate/master/sc_rpc/index.html

### Workshop: Intro

- Transfer tokens from one account to another.
- Transfer tokens from Alice to Bob.

<br/>

Expand All @@ -161,15 +161,13 @@ Notes:
### Workshop: Spin up your node

- Check out cli docs

```sh
./target/release/minimal-node --help
```

<br/>

- Spin up your dev node.

```sh
./target/release/minimal-node --chain=dev --tmp
```
Expand Down Expand Up @@ -215,7 +213,7 @@ wscat \
<br/>

- This itself is Scale Encoded. See [frame-metadata](https://github.com/paritytech/frame-metadata).
- Derive type of Balance using this metadata.
- Derive type of AccountInfo using this metadata.

<!-- .element: class="fragment" -->

Expand All @@ -228,36 +226,10 @@ Notes:

---v

### Workshop: Transfer some tokens

- Take PJS help to get the signed extrinsic.
- Use the following command to submit the extrinsic.

```sh
wscat \
-c ws://localhost:9944 \
-x '{"jsonrpc":"2.0", "id": 42, "method":"author_submitExtrinsic", "params": [""] }' \
| jq
```

<br/>

- Check balance again for both accounts.
- What happens to nonce of Alice?

<!-- .element: class="fragment" -->

Notes:

- Students will learn how to build the signed extrinsic themselves in their assignment.
- Let students do the second part themselves.

---v

### Workshop: Decoding balance

- Use https://www.shawntabrizi.com/substrate-js-utilities/codec/ to decode balance.
- Use the following balance struct
- Use [scale decoder](https://www.shawntabrizi.com/substrate-js-utilities/codec/) to decode balance.
- Use the following type information for AccountInfo.

```json
{
Expand Down Expand Up @@ -294,6 +266,26 @@ The actual type is:

---v

### Workshop: Transfer some tokens

- &shy;<!-- .element: class="fragment" --> Take PJS help to get the signed extrinsic.
- &shy;<!-- .element: class="fragment" --> Use the following command to submit the extrinsic.
```sh
wscat \
-c ws://localhost:9944 \
-x '{"jsonrpc":"2.0", "id": 42, "method":"author_submitExtrinsic", "params": [""] }' \
| jq
```
- &shy;<!-- .element: class="fragment" --> Check balance again for both accounts.
- &shy;<!-- .element: class="fragment" --> What happens to nonce of Alice?

Notes:

- Students will learn how to build the signed extrinsic themselves in their assignment.
- Let students do the second part themselves.

---v

### Workshop: Versions

- Find runtime version of the polkadot and westend chain `state_getRuntimeVersion`.
Expand Down Expand Up @@ -327,18 +319,8 @@ Notes:
https://github.com/JFJun/go-substrate-rpc-client
https://github.com/polkascan/py-substrate-interface
more here: https://project-awesome.org/substrate-developer-hub/awesome-substrate

---

## `subxt`

- Something analogous to `PJS` for Rust.
- The real magic is that it generates the types by fetching the metadata at compile time, or linking
it statically.
- ..It might need manual updates when the code, and therefore the metadata changes.

Notes:
Listen to James Wilson introducing subxt: https://www.youtube.com/watch?v=aFk6We_Ke1I

---

## Additional Resources! 😋
Expand Down Expand Up @@ -385,4 +367,13 @@ wscat -c wss://kusama-rpc.polkadot.io -x '{"jsonrpc":"2.0", "id":72, "method":"s
wscat -c wss://kusama-rpc.polkadot.io -x '{"jsonrpc":"2.0", "id":72, "method":"state_getStorage", "params": ["0x26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac", "0xdcbaa224ab080f2fbf3dfc85f3387ab21019355c392d79a143d7e50afba3c6e9"] }' | jq
```

Notice that this number that we get back is the little endian (SCALE) encoded value that we passed in at first.
Notice that this number that we get back is the little endian (SCALE) encoded value that we passed in at first.

---

## `subxt`

- Something analogous to `PJS api` for Rust.
- The real magic is that it generates the types by fetching the metadata at compile time, or linking
it statically.
- ..It might need manual updates when the code, and therefore the metadata changes.

0 comments on commit 354764d

Please sign in to comment.