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

ecash-rpc

v0.0.3

Published

JSON-RPC library for use with eCash Nodes, promise-based and async/await support.

Downloads

5

Readme

eCash JSON-RPC library

JavaScript library to communicate with your eCash Node.

Compatible with Avalanche Post-Consensus (0.26.x and later).

This is a promise-based library and async/await compatible.

Installation

1. Install from NPM

  npm i ecash-rpc

2. Node configuration

Configure your eCash Avalanche Node for remote RPC calls based on your node's security needs. This includes:

  • adding server=1, rpcallowip=, rpcbind= and rpcauth/rpcuser/rpcpassword= parameters to your node configuration in bitcoin.conf. (refer to the Server Configuration section of this Blockchain Dev guide)
  • a reverse proxy server such as nginx to serve RPC data to external web apps subject to your eCash node's rpcallowip whitelist
  • install a digital certificate (e.g. Let's Encrypt) on your node to enable HTTPS if desired

Usage

let ECashRPC = require("ecash-rpc");
let xecNode = new ECashRPC(
  host, // your eCash node e.g. 'https://hostname.blah'
  username,
  password,
  port,
  timeout, // timeout is 3000 by default
  debugging // debugging is true by default, false makes the library silent and requires try/catch on the app level.
);
 let info = await xecNode.getAvalancheInfo();

 console.log(info)

 // results in
 // {
 //  "ready_to_poll":true,
 //  "local":{
 //     "verified":true,
 //     "proofid":"...",
 //     "limited_proofid":"...",
 //     "master":"...",
 //     "payout_address":"ecash:qqmd..........",
 //     "stake_amount":1560000000
 //  },
 //  "network":{
 //     "proof_count":18,
 //     "connected_proof_count":18,
 //     "dangling_proof_count":0,
 //     "finalized_proof_count":18,
 //     "conflicting_proof_count":0,
 //     "immature_proof_count":4,
 //     "total_stake_amount":83681202831.85,
 //     "connected_stake_amount":83681202831.85,
 //     "dangling_stake_amount":0,
 //     "node_count":37,
 //     "connected_node_count":33,
 //     "pending_node_count":4
 //  }
 // }
 

or

 p = Promise.resolve(xecNode.getAvalancheInfo());
 p.then(info=>{
    console.log(info);
 })

Available Methods

There is only selected RPC coverage at the moment. Please submit a PR if you'd like to have a specific RPC method added.

addAvalancheNode buildAvalancheProof decodeAvalancheDelegation decodeAvalancheProof delegateAvalancheProof getAvalancheInfo getAvalancheKey getAvalanchePeerInfo getRawAvalancheProof isFinalBlock isFinalTransaction sendAvalancheProof verifyavalanchedelegation verifyAvalancheProof

getBlockchainInfo getBlockCount getWalletInfo getUnconfirmedBalance getBalance getBlockCount getWalletInfo getBlockHash setTxFee getBlock getTxOut listTransactions listUnspent getTransaction getRawTransaction getRawMempool signRawTransaction sendRawTransaction decodeRawTransaction getTxoutProof

Troubleshooting

Common errors:

  • Connection timeout: your app is failing to communicate with your node. Check firewall settings and node configuration whitelists.
  • Network errors: these errors can be misleading - in most cases your app is connecting to your node however is likely failing authentication. Check your RPC authentication parameters or your reverse proxy server settings.
  • CORS Policy errors: your app is encountering Cross-Origin Resource Sharing restrictions e.g. you may be using your local dev instance on http://localhost:3000 to connect to your eCash node on a separate host (https://someip:someport) See this article and nginx's headers module on how to address this.

Compatible Node Implementations

You must be running a Node (Pruned mode is fine)

Bitcoin ABC

Tested on Node v16.17.0, NPM v8.19.1 and Bitcoin ABC 0.26.2