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:

1.polkadot-js/api (Document)

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.

1) Dependent on

2) Install

1
yarn add @polkadot/api
Copied!

3) Examples

2.txwrapper apigithub)

Helper functions for offline transaction generation.

1) Dependent on

2) Install

1
yarn add @substrate/txwrapper
Copied!

3) de/encrypt, send transaction cases:

Note:
  • When developing StaFi App,you can use substrateMaster.ts
  • You can modify the node ip and port in util.ts.

4) api list

3.sidecar json api (github)

REST API service intended to run next to Substrate, exposing a limited set of endpoints over HTTP with meaningful responses.

1) Dependent on

2) Install

  • Install cargo if your machine does not already have it:
1
curl https://sh.rustup.rs -sSf | sh
Copied!
  • Install wasm-pack if your machine does not already have it:
1
cargo install wasm-pack
Copied!
  • Use yarn to do the remaining setup:
1
yarn
Copied!
  • Running
1
# For live reload in development
2
yarn dev
Copied!
1
# To build and run
2
cargo install wasm-pack
Copied!
1
#When you developing Stafi App,config/types.json can modified as follows:
2
{
3
"CUSTOM_TYPES": {}
4
}
Copied!

3) Api list

Last modified 5mo ago