StaFi_Protocol
Search
⌃K

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

yarn add @polkadot/api

3) Examples

2.txwrapper apigithub)

Helper functions for offline transaction generation.

1) Dependent on

2) Install

yarn add @substrate/txwrapper

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:
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": {}
}

3) Api list