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

cuff

v1.4.0

Published

blockchain tools for tracking and analysis

Downloads

17

Readme

Overview

cuff is a suite of blockchain tools for tracking and analysis.

Bitcoin and Etherium are currently supported.

cuff uses John-David Dalton's forward thinking and elegant @std/esm module for ES6 imports and exports on the back end; no transpilation step is required.

Installation

$ npm i --save cuff

or

$ yarn add cuff

You might need to add .esm-cache to your .gitignore

Methods and Usage

Bring relevant classes into your namespace.

const { Bitcoin, Etherium } = require('cuff');

Below is a list of currently available methods. All methods return a promise.

// top level data for the current state of the coin's blockchain
Bitcoin.blockchainInfo();
Etherium.blockchainInfo();

// data for a specific block in the chain
Bitcoin.blockInfo(blockHash);
Etherium.blockInfo(blockHash);

// data for specific transaction
Bitcoin.txInfo(txId);
Etherium.txInfo(txId);

// get bitcoin estimation of hashrate distrubtion among largest mining pools
const timespan = '12hours';
Bitcoin.miningPoolHashrateDistribution(timespan);

timespan can be expressed in hours or days, also accepting d or h abbreviations, e.g., 3d, 18h, etc.

Examples

const { Bitcoin, Etherium } = require('cuff');

Bitcoin.blockchainInfo()
  .then(data => {
    console.info(data);
  })
  .catch(err => {
    console.info('Error:', err)
  });


Etherium.blockchainInfo()
  .then(data => {
    console.info(data);
    })
  .catch(err => {
    console.info('Error:', err);
  });

Sample Output

Bitcoin.blockchainInfo().then(data => console.info(data));

{
  "name": "BTC.main",
  "height": 488733,
  "hash": "0000000000000000005d1ec542fda806c5ee9a27781812e161f6ae135d1b825d",
  "time": "2017-10-07T17:53:09.761213067Z",
  "previous_hash": "000000000000000000e39bd308bca48bb5339fc52ba246323870839f33c7421d",
  "peer_count": 994,
  "unconfirmed_count": 12845,
  "high_fee_per_kb": 124705,
  "medium_fee_per_kb": 110000,
  "low_fee_per_kb": 90000,
  "last_fork_height": 487958,
  "last_fork_hash": "0000000000000000005c5028bbbc9f3d472e85144f2698ad9fb4e1dd95fc9d93"
}
const txId = '45b263b0ebb9acefc78f9bfdcdbdbf3cd1439cb8344d52b84ed793d67726a224';
Etherium.txInfo(txId).then(data => console.info(data));

{
  "block_hash": "0f1803b7e29a4b73a3cd69913d67b037249284094202e68c6e82b6aee0bc9155",
  "block_height": 4347981,
  "block_index": 56,
  "hash": "45b263b0ebb9acefc78f9bfdcdbdbf3cd1439cb8344d52b84ed793d67726a224",
  "addresses": [
    "3b0bc51ab9de1e5b7b6e34e5b960285805c41736",
    "f4e659f164044b65f28739b34c67a8d3644ad32e"
  ],
  "total": 511638030000000000,
  "fees": 630000000000000,
  "size": 113,
  "gas_limit": 50000,
  "gas_used": 21000,
  "gas_price": 30000000000,
  "confirmed": "2017-10-08T15:15:57Z",
  "received": "2017-10-08T15:15:11.945Z",
  "ver": 0,
  "double_spend": false,
  "vin_sz": 1,
  "vout_sz": 1,
  "confirmations": 238,
  "confidence": 1,
  "inputs": [
    {
      "sequence": 73373,
      "addresses": [
        "3b0bc51ab9de1e5b7b6e34e5b960285805c41736"
      ]
    }
  ],
  "outputs": [
    {
      "value": 511638030000000000,
      "addresses": [
        "f4e659f164044b65f28739b34c67a8d3644ad32e"
      ]
    }
  ]
}

Custom Response Payloads

What if you don't need every property in the response object? Maybe you want to be lean and mean: you need only a few keys. With an optional list of object properties included in the call, say good riddance to unwanted clutter!

Bitcoin.blockchainInfo('time', 'peer_count').then(data => console.info(data));

{
  "time": "2017-10-07T17:53:09.761213067Z",
  "peer_count": 994
}

// Array syntax is also supported
const txId = '45b263b0ebb9acefc78f9bfdcdbdbf3cd1439cb8344d52b84ed793d67726a224';
const props = ['gas_limit', 'gas_used', 'gas_price'];
Etherium.txInfo(txId, props).then(data => console.info(data));

{
  "gas_limit":50000,
  "gas_used":21000,
  "gas_price":30000000000
}

The Future

cuff's philosophy is to maintain currency with the avant-garde progress of the trustworthy economy. We are likewise committed to providing simple and clear interfaces for the developer.

More extensive functionality will be forthcoming.

Have fun!

Gerry Gold
October 2017