polkadot_apps
Interacting with Polkadot
Setup
- Ensure that you have recent versions of Node and Yarn
- Install dependencies with
yarn
- you may also have to doyarn add @polkadot/api@beta
- To run,
node foo.js
Kinds of Calls
- Constants - A constant feature of the chain. These are things that the API does not need to do any work to get, they can just see the value.
- Queries - These are basically function calls to get some data.
- Tx - Issue an actual on-chain extrinsic. Note that even though this looks like it would only contain transactions, it is for any extrinsic.
- Events - Listening for events occurring on-chain.
Basic Connection
Connect to Kusama
See basic_connect.js
Connect to local node (could be connected to Kusama, running local chain, etc.)
Reading Constants
Calling Functions
See read_account.js
Script to Check Balances
Subscribing to Events
See display_data.js
Transactions
See tx.js
See better_tx.js
A More Complex Script
See Anson Lau's Validator Stats script
Moving Beyond
- Dig into the API https://polkadot.js.org/api/
- Start programming the UI https://polkadot.js.org/ui/start/
- polkadot.js source and links to other tutorials: https://github.com/polkadot-js/apps
- Various CLI tools to help your development https://github.com/polkadot-js/tools
- Dealing with types, enums, structs, etc. https://polkadot.js.org/api/start/types.basics.html