substrate-seminar icon indicating copy to clipboard operation
substrate-seminar copied to clipboard

[Topic Request]: Node interaction with Subxt

Open sacha-l opened this issue 2 years ago • 3 comments

Description

I think it'd be super valuable to have someone from the Subxt team do a seminar walking through some examples of using Subxt, highlighting its key features, especially with all the updates it's seen in the past ~12 months.

@ascjones @jsdw would you be interesting in doing something like this? We could use this repo as basis: https://github.com/paritytech/polkadot-interaction-examples-rs (and perhaps take the opportunity to update it with more examples too!). What do you think?

Topic

subxt, node interaction

Additional information

  • https://github.com/paritytech/polkadot-interaction-examples-rs
  • https://github.com/paritytech/subxt/tree/master/examples

How advanced is this topic in terms of pre-requisite knowledge of Substrate?

Intermediate

sacha-l avatar Jan 09 '23 19:01 sacha-l

Heyhey, yeah I'd be up for this! What sort of audience/date/time/format did you have in mind?

You may already know, but my Sub0 presentation was on roughly the same topic:

https://docs.google.com/presentation/d/1r2bzznGJLrvlDAPCjAHa-27QJl4DDregbauvNa0Zqzs/edit?usp=sharing

Though something that dug into how some bits worked under the hood first (ie what https://github.com/paritytech/polkadot-interaction-examples-rs does) and then shows how subxt does that for you next would be very cool and maybe more interesting for anybody wanting to learn about how to interact with a node (and not just specifically learn about subxt)

jsdw avatar Jan 10 '23 10:01 jsdw

Love that idea, concretely:

  1. Cover the basics of what you need to know in order to interact with a node. What comes to mind are things like:
  • Transaction format
  • SCALE encoding and decoding
  • Metadata and types
  • Node endpoints / providers
  • Handling node upgrades, runtime version changes

(anything I'm missing?)

  1. Show how subxt makes it easy for you to interact with a node by walking through a demo.

One thing that comes to mind is that we could make this seminar more like a fun workshop if we actually built something useful in 2. For example: "A fee estimator for creating NFT collections" or "Build a component for sending a remark to Polkadot from a Zola webapp". Any ideas ? Perhaps @gilescope has some ideas? 😃

sacha-l avatar Jan 24 '23 16:01 sacha-l

Offhand, what comes to mind for me is a format vaguely like this (but let's see what happens):

  • A bit of basic theory; we have blocks. Blocks contain transactions. Transactions modify storage. (Storage also contains events associated with each transaction).
  • Metadata is provided which describes what transactions can be submitted and what storage is available and what shape these things have.
  • So, we'll want to know how to submit a transaction, how to view submitted transactions, and how to view storage values.
  • Well, interacting with a node happens over an HTTP/WS based JSON interface based on a standard called JSONRPC.
  • Let's start by trying to submit a transaction. Transaction format, SCALE encoding, looking at metadata for it
  • Now let's try accessing some storage to see what effect that had. Storage request format, metadata.
  • Subxt can take this metadata and provide an interface for you to make this all easy. Same examples again using Subxt.

And yes, perhaps after this "explanation/slides" bit we can have a workshop/live coding bit where there is some simple CLI app we could build then which uses subxt to do something! Maybe we can do some part of it and set a challenge to complete it to have it do X. But yeah, ideas welcome!

jsdw avatar Jan 24 '23 17:01 jsdw