Polkadot JS API Crash Course
Context
- De facto library to work with all FRAME-based substrate runtimes.
Overview
Overview
api.registry
api.rpc
@polkadot/keyring
.@polkadot/utils
.
Overview
Almost everything else basically builds on top of api.rpc
.
api.tx
api.query
api.consts
api.derive
api
api.registry
api.rpc
- Can call into all RPC endpoints of the chain.
All endpoints are divided based on on scope and method, such as
scope_method
, e.g.system_chain
.
Keyring
api.tx
Types
createType
A powerful tool to keep in mind.- everything is
Codec
by default, and hastoHuman
,toU8a
,toHex
,toString
and.eq
.
Crypto Utils
api.query
api.query.[module_name].[storage_name]()
api.query.[module_name].[map_name](key)
api.query.[module_name].[map_name].entries()
api.query.[module_name].[double_map_name](key1, key2)
api.consts
api.consts.[config_name]()
api.derive
Helpers that combine multiple calls and queries into one. Entirely optional to use.
Exercise: Using Polkadot JS API
- Find the some interesting blocks in Polkadot/Kusama:
- The largest block
- The block that consumed the most weight.
- Last remark that Shawn made onchain??? 🤔
- Bonus: use subxt.