1.0.8 • Published 1 month ago

@therootnetwork/api v1.0.8

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
1 month ago

@therootnetwork/api

A utility package that complements the @polkadot/api to connect and interact with the Root Network node.

Install

yarn add @polkadot/api @therootnetwork/api
yarn add -D @therootnetwork/api-types # optional, for Typescript support

Usage

  • Create an API instance
import "@therootnetwork/api-types"; // optional, for Typescript support
import { ApiPromise } from "@polkadot/api";
import { getApiOptions, getPublicProvider } from "@therootnetwork/api";

const api = await ApiPromise.create({
  ...getApiOptions(),
  ...getPublicProvider("root"),
});
  • Use api instance to interact with node
// query and display account data
const data = await api.query.system.account("0xE04CC55ebEE1cBCE552f250e85c57B70B2E2625b");
console.log(data.toHuman());

TypeScript Support

See api-types for more details

API

function getApiOptions()

Returns an ApiOptions object that contains necessary types, rpc methods to connect the Root Network

function getPublicProvider(network: NetworkName, useWsProvider?: boolean, useArchiveNode?: boolean)

Returns a provider instance of either WsProvider or HttpProvider that connects to TRN mainnet "root" or testnet "porcini"

function getPublicProviderUrl(network: NetworkName, useWsProvider?: boolean, useArchiveNode?: boolean)

Used by getPublicProvider, simply returns public URL for the provider

1.0.8

1 month ago

1.0.7

3 months ago

1.0.7-next.0

3 months ago

1.0.7-next.1

3 months ago

1.0.2

10 months ago

1.0.6

6 months ago

1.0.5

8 months ago

1.0.4

9 months ago

1.0.3

9 months ago

1.0.1

11 months ago

1.0.0

11 months ago