huang-lei1 / setheum.js

Promise and RxJS APIs around Setheum and related Substrate-based chain RPC calls. It is dynamically generated based on what the Substrate runtime provides in terms of metadata and tuned with SetheumJS and Setters.JS for Setheum Networks. Full documentation & examples available

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

license npm

@setheum-js

Promise and RxJS APIs around Setheum RPC calls. This library provides additional typing for users to access Setheum networks by using setheum.js.

Getting Started

More documentation and examples on setheum.js.org.

  • Install dependencies
yarn add @polkadot/api @setheum-js/api@beta
  • Create API instance
import { ApiPromise } from '@polkadot/api';
import { WsProvider } from '@polkadot/rpc-provider';
import { options } from '@setheum-js/api';

async function main() {
    const provider = new WsProvider('ws://127.0.0.1:9944');
    const api = new ApiPromise(options({ provider }));
    await api.isReady;

    // use api
}

main()
  • Use api to interact with node
// query and display account data
const data = await api.query.system.account('5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY');
console.log(data.toHuman())

overview

The API is split up into a number of internal packages -

  • @setheum-js/api The API library, providing both Promise and RxJS Observable-based interfaces. This is the main user-facing entry point.
  • @setheum-js/api-derive Additional polkadot.js derives for Setheum Network. Derived results that are injected into the API, allowing for combinations of various query results (only used internally and exposed on the Api instances via api.derive.*)
  • @setheum-js/app-util
    • Utilities to work with Setheum
  • @setheum-js/types Codecs for all Polkadot.js type definations for Setheum primitives

About

Promise and RxJS APIs around Setheum and related Substrate-based chain RPC calls. It is dynamically generated based on what the Substrate runtime provides in terms of metadata and tuned with SetheumJS and Setters.JS for Setheum Networks. Full documentation & examples available

License:Apache License 2.0


Languages

Language:TypeScript 99.6%Language:JavaScript 0.4%