Added polkadot storage page into docs

This commit is contained in:
Alexander Krupenkin 2021-01-15 08:49:15 +03:00
parent 6d7ac3547a
commit af105e02d4
No known key found for this signature in database
GPG Key ID: 8858C018FBC3725E
2 changed files with 27 additions and 0 deletions

View File

@ -9,6 +9,7 @@ Haskell Web3 Documentation
getting_started
ethereum_node_api
polkadot_node_api
polkadot_storage
ethereum_accounts
smart_contracts
ipfs_client_api

26
docs/polkadot_storage.rst Normal file
View File

@ -0,0 +1,26 @@
Polkadot Storage
================
Blockchains that are built with Substrate expose a remote procedure call (RPC) server
that can be used to query runtime storage. In Haskell Web3 the standard Web3 provider could be used.
Lets try to query Polkadot storage with ``runWeb3'`` function using ``ghci``.
.. code-block:: haskell
> import Network.Web3.Provider
> import Network.Polkadot
> runWeb3' (WsProvider "127.0.0.1" 9944) (query "timestamp" "now" [] :: Web3 (Either String Moment))
Right (Right 1610689972001)
The ``query`` function arguments is **section** (or module), **method** and list of arguments (for maps and double maps).
.. code-block:: haskell
query :: (JsonRpc m, Decode a) => Text -> Text -> [Argument] -> m a
Where ``a`` type should be SCALE decodable.
.. note::
More usage details available in `Polkadot example <https://github.com/airalab/hs-web3/tree/master/examples/polkadot>`_ app.