Polka JS Library
To facilitate the access of wallets, browsers and other tools, StaFi chose Substrate. We have also sorted mature js api database, such as polkadot-js/api, which can interact with StaFi through wss, or txwrapper, which can build transaction data through api to support offline transactions. Meanwhile, sidecar can interact with StaFi through http rpc api. The details are as follows:
The API provides application developers the ability to query a node and interact with the Polkadot or Substrate chains using Javascript. Here you will find documentation and examples to get you started.
- npm
yarn add @polkadot/api
- transactions (Ordinary transactions, batch transactions, manual nonce transactions, etc.): https://polkadot.js.org/api/cookbook/tx.html
Helper functions for offline transaction generation.
- npm
yarn add @substrate/txwrapper
Note:
- When developing StaFi App,you can use substrateMaster.ts
- You can modify the node ip and port in util.ts.
REST API service intended to run next to Substrate, exposing a limited set of endpoints over HTTP with meaningful responses.
- npm
- cargo
- Install cargo if your machine does not already have it:
curl https://sh.rustup.rs -sSf | sh
- Install wasm-pack if your machine does not already have it:
cargo install wasm-pack
- Use yarn to do the remaining setup:
yarn
- Running
# For live reload in development
yarn dev
# To build and run
cargo install wasm-pack
#When you developing Stafi App,config/types.json can modified as follows:
{
"CUSTOM_TYPES": {}
}
- The node ip and port can be configured as follows: https://github.com/stafiprotocol/substrate-api-sidecar/blob/master/specs.yml
Last modified 1yr ago