6.20.0 • Published 4 years ago

orbs-pos-data v6.20.0

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

Orbs PoS Data V1

A library that provides a simple way to read data about the Orbs PoS V1, like Guardians, rewards, etc.

Installation

npm install orbs-pos-data --save

Requirements

  • If you are using this library on a browser, make sure that you can provide a web3 instance in version 1.2.1 and up (Probably via metamask), also make sure that you have orbs-client-sdk instance.

Setup - NodeJs

import { orbsPOSDataServiceFactory } from "orbs-pos-data";
import Web3 from "web3";
import { Client, NetworkType } from "orbs-client-sdk";

// web3 instance
const ethereumProviderUrl = 'https://mainnet.infura.io/v3/YOUR_KEY';   // The Ethereum that we will query
const web3 = new Web3(new Web3.providers.HttpProvider(ethereumProviderUrl));

// orbs client instance
const virtualChainId = 1100000; // The virtual chain ID on the Orbs network
const orbsNodeUrl = `http://18.197.127.2/vchains/${virtualChainId.toString()}`;
const orbsClient = new Client(
  orbsNodeUrl,
  virtualChainId,
  NetworkType.NETWORK_TYPE_TEST_NET
);

const orbsPosData = orbsPOSDataServiceFactory(web3, orbsClient);

Setup - Browser

import { orbsPOSDataServiceFactory } from "orbs-pos-data";
import Web3 from "web3";
import { Client, NetworkType } from "orbs-client-sdk";

// creating the web3 instance
let provider;
if ((window as any).ethereum) {
  // Using existing "window.ethereum" provider [MetaMask]'
  provider = (window as any).ethereum;
} else {
  // Using your own "infura" provider
  const ethereumProviderUrl = 'https://mainnet.infura.io/v3/YOUR_KEY';
  provider = new Web3.providers.HttpProvider(ethereumProviderUrl);
}
const web3 = new Web3(provider);

// create the orbs-client-sdk instance
const orbsNodeAddress = '18.197.127.2';  // The Orbs node that we will query
const virtualChainId = 1100000;          // The virtual chain Id on the Orbs network
const orbsNodeUrl = `http://${orbsNodeAddress}/vchains/${virtualChainId.toString()}`;
const orbsClient = new Client(orbsNodeUrl, virtualChainId, NetworkType.NETWORK_TYPE_TEST_NET);

const orbsPosData = orbsPOSDataServiceFactoryIOC(web3, orbsClient);

Usage

readValidators(): Promise<string[]>

Get a list of Orb's Validators addresses.


readValidatorInfo(validatorAddress: string): Promise<IValidatorInfo>

Get detailed information about the given Validator.

interface IValidatorInfo {
  name: string;
  ipAddress: string;
  website: string;
  orbsAddress: string;
  votesAgainst: number;
}

readTotalParticipatingTokens(): Promise<number>

Get the current total number of participating ORBS in the POS.


readRewards(address: string): Promise<IRewards>

Get information about all the rewards of a given address.

export interface IRewards {
  delegatorReward: bigint;
  guardianReward: bigint;
  validatorReward: bigint;
}

readRewardsHistory(address: string): Promise<IRewardsDistributionEvent[]>

Get a list of all the rewards distrebution events to a given address.

interface IRewardsDistributionEvent {
  distributionEvent: string;
  amount: number;
  transactionHash: string;
}

readUpcomingElectionBlockNumber(): Promise<number>

Get the upcoming election block number (on Ethereum)


readEffectiveElectionBlockNumber(): Promise<number>

Get the effective election block number (on Ethereum)


readElectedValidators(): Promise<string[]>

Get a list of the currently elected Validator's addresses.


readElectedValidatorInfo(validatorAddress: string): Promise<IElectedValidatorInfo>

Get a detailed information about the given Validator.


readOrbsBalance(address: string): Promise<bigint>

Get the amount of ORBS the given address is holding.


subscribeToORBSBalanceChange(address: string, callback: (newBalance: string) => void): Promise<() => void>

Listen to ORBS balance changes on the given address. The given callback will be fired on the balance. This function returns the unsubscribe function. call it to unsubscribe.

6.20.0

4 years ago

6.19.0

4 years ago

6.17.0

4 years ago

6.18.0

4 years ago

6.16.0

4 years ago

6.15.0

4 years ago

6.14.0

4 years ago

6.13.0

4 years ago

6.12.0

4 years ago

6.11.0

4 years ago

6.10.0

4 years ago

6.8.0

4 years ago

6.9.0

4 years ago

6.7.0

4 years ago

6.5.0

4 years ago

6.6.0

4 years ago

6.4.0

4 years ago

6.3.0

4 years ago

6.2.0

4 years ago

6.1.3

4 years ago

6.1.2

4 years ago

6.1.1

4 years ago

6.1.0

4 years ago

5.2.0

4 years ago

6.0.0

4 years ago

5.1.2

4 years ago

5.1.1

4 years ago

5.1.0

4 years ago

5.0.2

4 years ago

5.0.1

4 years ago

4.5.0

4 years ago

4.4.0

4 years ago

4.3.0

4 years ago

4.2.0

4 years ago

3.2.0

4 years ago

4.1.0

4 years ago

4.0.0

4 years ago

3.1.0

4 years ago

3.0.4

4 years ago

3.0.2

4 years ago

3.0.1

4 years ago

3.0.0

4 years ago

2.0.0

4 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.2.12

5 years ago

1.2.11

5 years ago

1.1.14

5 years ago

1.1.13

5 years ago

1.1.12

5 years ago

1.1.11

5 years ago

1.1.10

5 years ago

1.1.9

5 years ago

1.1.8

5 years ago

1.1.7

5 years ago

1.1.5

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago