npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

orbs-pos-data

v6.20.0

Published

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

Downloads

87

Readme

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.