/subxt-workshop

Subxt Workshop for Polkadot Decoded 2022

Primary LanguageRust

Subxt Workshop (Polkadot Decoded 2022)

Getting Started

Install Rust

Follow the Substrate docs.

Download Polkadot

curl "https://github.com/paritytech/polkadot/releases/download/v0.9.18/polkadot" --output /usr/local/bin/polkadot --location

Instructions

Run the Polkadot node in a separate terminal:

polkadot --dev --tmp

> 2022-06-23 21:43:57 Parity Polkadot    
> 2022-06-23 21:43:57 ✌️  version 0.9.18-99cd17ddb2-x86_64-linux-gnu    
> 2022-06-23 21:43:57 ❤️  by Parity Technologies <admin@parity.io>, 2017-2022    
> 2022-06-23 21:43:57 📋 Chain specification: Development    
> ...

Run the test suite:

cargo test

Notice the test failures, your task is to implement the helper functions. The files in the tests/ directory are ranked in order of difficulty.

  1. Exercise 01 - Get the block number for a given block_hash.
  2. Exercise 02 - Get the free balance of an account.
  3. Exercise 03 - Sum the total frozen balance.
  4. Exercise 04 - Fetch the first n accounts from storage.
  5. Exercise 05 - Return the embedded RuntimeVersion.
  6. Exercise 06 - Transfer an amount from the signer to dest.
  7. Exercise 07 - Estimate the fees for an extrinsic using a custom RPC.
  8. Exercise 08 - Make multiple transfers in the same call.
  9. Exercise 09 - Create a spending proposal and check the deposit.
  10. Exercise 10 - Listen and approve multisig operations.

Other Notes

Refresh Metadata

This is only required if you change the node / runtime.

cargo install subxt-cli
subxt metadata -f bytes > polkadot_metadata.scale

Examine Metadata

Verbose but helpful expansion of the generated Rust code.

cargo install cargo-expand
cargo expand

Credits

Thanks to all subxt / substrate maintainers and contributors.