Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@equilab/api

Package Overview
Dependencies
Maintainers
1
Versions
198
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@equilab/api

JS API for equilibrium polkadot substrate; beta branch

  • 0.3.0-beta.7
  • npm
  • Socket score

Version published
Weekly downloads
35
increased by25%
Maintainers
1
Weekly downloads
 
Created
Source

EQUILIBRIUM API

API bindings to access Equilibruim substrate queries and transactions
NOTE Typescript bindings included

Installation

$ npm i --save @equilab/api # if you are using npm or  
$ yarn add @equilab/api     # for yarn package manager  

Usage

Use createApi(node: string) factory from @equilab/api package

import { createApi } from "@equilab/api";  

(async () => { // async/await usage
  // Connect to TGE node with websocket
  const api = await createApi("wss://alice.tge-testnet-release.equilibrium.io");
  // do the interaction below
  const balance = await api.getBalance("YOUR_ADDRESS", "EQ"); // get EQ tokens
})();

createApi("wss://alice.tge-testnet-release.equilibrium.io")
.then(api => api.getBalance("YOUR_ADDRESS", "EQ"))
.then(balance => console.log(balance.toJSON())); // Promise usage

Methods

  • api.setSigner(signer: Signer) - sets transaction signer, can be used with injected wallet
  • api.multi(...) - useful for subscribing to multiple queries
  • api.claim(address: string, signature: string) - create claim transaction
import { createApi } from "@equilab/api";
import { u8aToHex } from "@polkadot/util";
import { decodeAddress } from "@polkadot/util-crypto";
import Web3 from "web3";
const polkadotAddress = "5DnoYz3koaRcMZ9Hj4FmQ2nNRKQfS73yBmEzzM9SsPn9cLtb";
const ethAddress = "0xE372d786E3E6529BBe9CeA4040466531E2Ac4796";
const web3 = new Web3(Web3.givenProvider);
const message = `Pay EQ to the account:${u8aToHex(decodeAddress(account.address), -1, false)}`;

Promise.all([
  createApi("wss://alice.tge-testnet-release.equilibrium.io"),
  web3.current.eth.personal.sign(message, ethAddress)
]).then(([api, message]) => api.claim(polkadotAddress, sig).send() /* transaction must be unsigned */) 
  • api.vest() - claim unlocked vested amount for current address
createApi(...).then(api => api.vest().signAndSend(YOUR_ADDRESS)) // transaction must be signed with destination address
  • api.getBalance(address: string, currency) - query balance, NOTE you can call multi to subscribe to multiple address or currencies balance change
const subscribeToEQBalances = async (...addresses: string[]) => {
  const api = await createAPI(NODE);
  const unsub = await api.getBalance.multi(
    addresses.map(address => [address, "EQ"]),
    (balances) => console.log(balances)
  );

  return unsub; // call this function to unsubscribe
}
  • api.getClaim
  • api.getClaimSigning
  • api.getClaimVesting
  • api.getTotalClaim
  • api.getVested
  • api.getVesting

FAQs

Package last updated on 09 Oct 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc