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

raiblocks-js

v0.5.1

Published

Raiblocks RPC client

Downloads

26

Readme

npm version Build Status Coverage Status

Imgur

RaiBlocksJS

An isomorphic async library that interfaces with the RaiBlocks RPC protocol https://github.com/clemahieu/raiblocks/wiki/RPC-protocol

Optimized for version 8+

Installation

yarn add raiblocks-js

Note

To test locally, you'll need to setup your own node. See instructions here: https://github.com/clemahieu/raiblocks/wiki/Docker-node

Usage

Boilerplate

https://gist.github.com/orrybaram/b1c4b724b134c8b7fb0cafe52cb5f6c6

Basic implementation

import Rai from 'raiblocks-js';

const rai = new Rai(); // creates default connection to localhost:7076
const blockCount = rai.blocks.count(); // returns Promise with a response object
blockCount.then(res => console.log(res)) // => { count: '1000', unchecked: '10' }

const accountWeight = rai.account.weight({ account: 'xrb_35jjmmmh81kydepzeuf9oec8hzkay7msr6yxagzxpcht7thwa5bus5tomgz9' });
accountWeight.then(res => console.log(res)) // => 1000000

Creating raw rpc actions

const rai = new Rai();
const blockCount = rai.rpc('block_count'); // returns Promise with a response object
blockCount.then(res => console.log(res)) // => { count: '1000', unchecked: '10' }

const accountWeight = rai.rpc('account_weight', { account: 'xrb_35jjmmmh81kydepzeuf9oec8hzkay7msr6yxagzxpcht7thwa5bus5tomgz9' });
accountWeight.then(res => console.log(res)) // => 1000000

Connecting to a custom node

const rai = new Rai('https://xrb.example-node.io:3000');

A note about import vs require:

If you are not using es modules, you'll need to reference the default value:

  const { default: Rai } = require('raiblocks-js');

Methods

rai.account

balance()

blockCount()

create()

info()

history()

get()

key()

list()

move()

remove()

getRepresentative()

setRepresentative()

weight()

rai.accounts

balances()

create()

frontiers()

pending()

rai.blocks

account()

count: getCount()

countByType()

chain()

create()

process()

get()

rai.bootstrap()

rai.delegators

count()

get()

rai.frontiers

count: ()

get()

rai.keys

create()

deterministic()

expand()

rai.ledger

get()

history()

succesors()

rai.network

availableSupply()

keepAlive()

republish()

rai.node

version()

stop()

rai.payment

begin()

init()

end()

wait()

rai.peers

addWorkPeer()

getWorkPeers()

clearWorkPeers()

get()

rai.pending

get()

exists()

search()

rai.proofOfWork

cancel()

get()

generate()

set()

rai.receive

get()

minimum()

setMinimum()

rai.representatives

get()

wallet()

walletSet()

rai.send()

rai.unchecked

clear()

get()

keys()

list()

rai.wallet

add()

balanceTotal()

balances()

changeSeed()

contains()

create()

destroy()

export: exportWallet()

frontiers()

locked()

passwordChange()

passwordEnter()

passwordValid()

pending()

getRepresentative()

setRepresentative()

republish()

unlock()

workGet()

Extended Methods

rai.extended

change()

checkSignature()

open()

proofOfWork()

receive()

seedKey()

seedKeys()

send()

RPC improvement progress here: https://github.com/clemahieu/raiblocks/issues/29