# Commands ## Substrate CLI - Clone substrate node template ```sh git clone https://github.com/paritytech/polkadot-sdk.git git checkout polkadot-v1.6.0 ``` - Compile node ```sh cargo build --release -p minimal-node ``` - Docs ```sh ./target/release/minimal-node --help ``` - Run node ```sh ./target/release/minimal-node --chain=dev --tmp ``` ## JSON-RPC - Get all rpc methods exposed by the node. ```sh wscat \ -c ws://localhost:9944 \ -x '{"jsonrpc":"2.0", "id": 42, "method":"rpc_methods" }' \ | jq ``` - Read a storage key ```sh wscat \ -c ws://localhost:9944 \ -x '{"jsonrpc":"2.0", "id": 42, "method":"state_getStorage", "params": [""] }' \ | jq ``` - Submit an extrinsic to the node ```sh wscat \ -c ws://localhost:9944 \ -x '{"jsonrpc":"2.0", "id": 42, "method":"author_submitExtrinsic", "params": [""] }' \ | jq ``` - Get runtime version ```sh wscat \ -c ws://localhost:9944 \ -x '{"jsonrpc":"2.0", "id": 42, "method":"state_getRuntimeVersion" }' \ | jq ``` - Get node version ```sh wscat \ -c ws://localhost:9944 \ -x '{"jsonrpc":"2.0", "id": 42, "method":"system_version" }' \ | jq ``` - Get Metadata ```sh wscat \ -c ws://localhost:9944 \ -x '{"jsonrpc":"2.0", "id": 42, "method":"state_getMetadata" }' \ | jq ``` # Decoding Storage ## Storage keys - balance_alice ``` 0x26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da9de1e86a9a8c739864cf3cc5ec2bea59fd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d ``` - balance_bob ``` 0x26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da94f9aea1afa791265fae359272badc1cf8eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a48 ``` ## Account Info type This is not the actual type. Try figure out the exact type from looking at the metadata at https://hackmd.io/@ak0n/rJUhmXmK6. ```json { "info": { "nonce": "u32", "ignore": "(u32, u32, u32)", "balance": { "free": "u64", "ignore": "(u64, u64, u128)" } } } ``` # Links: - PJS Explorer: https://polkadot.js.org/apps/#/explorer - Metadata with most details stripped off that are not relevant for deriving the Balance struct: https://hackmd.io/@ak0n/rJUhmXmK6 - SCALE decoder: https://www.shawntabrizi.com/substrate-js-utilities/codec/