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

infoblock

v1.0.4

Published

A typed wrapper of the blockchain.info API

Downloads

2

Readme

Infoblock

A typescript module for interacting with the blockchain.info.

Installation

npm install infoblock

API

Initialization

const infoblock = require('infoblock')

Methods

getLatestBlock()

Fetches the latest block

const latestBlock = infoblock.getLatestBlock()

/*
  Block {
    hash: '0000000000000000000b99a912590820bc610c0c448e7d08bd5076680e171c84',
    time: 2021-10-03T11:44:21.000Z,
    height: 703360,
    previousBlockHash: '0000000000000000000e928aac5b6c2f8906477a9e8cc45a10e93d136288fa41',
    merkleTreeRoot: '04c017abe57e0bcbd482394647709e2a7f72a71dcef9f57c01fee1a09e63bd82',
    transactions: [
      Transaction {
        hash: '161e42dc4db029ca3b5971fb0268e0f05fbb4e91dc2283b8239c357e565f1086',
        time: 2021-10-03T11:44:21.000Z,
        fee: 0,
        blockHeight: 703360,
        txInputs: [Array],
        txOutputs: [Array]
      },
      ...
    ]
  }
*/

getBlock(hash: string)

Fetches a block given its block hash

const blockHash = '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f'
const latestBlock = infoblock.getBlock(blockHash)

/*
  Block {
    hash: '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f',
    time: 2009-01-03T18:15:05.000Z,
    height: 0,
    previousBlockHash: '0000000000000000000000000000000000000000000000000000000000000000',
    merkleTreeRoot: '4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b',
    transactions: [
      Transaction {
        hash: '4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b',
        time: 2009-01-03T18:15:05.000Z,
        fee: 0,
        blockHeight: 0,
        txInputs: [Array],
        txOutputs: [Array]
      }
    ]
  }
*/

getBlockByHeight(height: number)

Fetches a block given its block height

const firstBlock = await infoblock.getBlockByHeight(0)

/*
  Block {
    hash: '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f',
    time: 2009-01-03T18:15:05.000Z,
    height: 0,
    previousBlockHash: '0000000000000000000000000000000000000000000000000000000000000000',
    merkleTreeRoot: '4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b',
    transactions: [
      Transaction {
        hash: '4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b',
        time: 2009-01-03T18:15:05.000Z,
        fee: 0,
        blockHeight: 0,
        txInputs: [Array],
        txOutputs: [Array]
      }
    ]
  }
*/

getTransaction(txId: string)

Fetches a transaction given its hash

const transactionID = 'a1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d'
const transaction = await infoblock.getTransaction(transactionID)

/*
  Transaction {
    hash: 'a1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d',
    time: 2010-05-22T18:16:31.000Z,
    fee: 99000000,
    blockHeight: 57043,
    txInputs: [
      TransactionInput {
        scriptSig: '493046022100bc57dc26f46fecc1da03272cb2298d8a08b22d865541f5b3a3e862cc87da4b47022100ce1fc72771d164d608b15065832542a0e9040cfdf28862c5175c81fcb0e0b65501410434417dd8d89deaf0f6481c2c160d6de0921624ef7b956f38eef9ed4a64e36877be84b77cdee5a8d92b7d93694f89c3011bf1cbdf4fd7d8ca13b58a7bb4ab0804',
        previousTxOutput: [TransactionOutput],
        witness: undefined
      },
	  ...
    ],
	txOutputs: [
      TransactionOutput {
        amount: 1000000000000,
        scriptPubKey: '76a91446af3fb481837fadbb421727f9959c2d32a3682988ac',
        address: '17SkEw2md5avVNyYgj6RiXuQKNwkXaxFyQ',
        spent: true
      },
	  ...
    ]
  }
*/

getUnconfirmedTransactions()

Fetches all unconfirmed transactions

const unconfirmedTransactions = await infoblock.getUnconfirmedTransactions()

/*
  [
	Transaction {
	  hash: 'd32a7e1087405bc11f0a952fae6acd0219ea4624868bd20f1af68554e4202ef0',
	  time: 2021-10-03T12:05:16.000Z,
	  fee: 225,
	  blockHeight: null,
	  txInputs: [ [TransactionInput] ],
	  txOutputs: [ [TransactionOutput], [TransactionOutput] ]
	},
	...
  ]
*/

getAddress(address: string)

Fetches all details and transactions of a given address

const address = '1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa'
const getAddress = infoblock.getAddress(address)

/*
  Address {
    address: '1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa',
    transactionsCount: 3058,
    unredeemedTransactionsCount: 3058,
    balance: 6852268489,
    totalSent: 0,
    totalReceived: 6852268489,
    transactions: [
      Transaction {
        hash: '6457fadd57078fa136658de0608e4ceaaf16f164020587d2b24fbae097773bde',
        time: 2021-10-02T04:56:30.000Z,
        fee: 146,
        blockHeight: 703134,
        txInputs: [Array],
        txOutputs: [Array]
      },
	  ...
    ]
  }
*/

getDifficulty()

Fetches the current difficulty target

const difficulty = await infoblock.getDifficulty()
// 18997641161758

getBlockCount()

Fetches the current block height in the longest chain

const count = await infoblock.getBlockCount()
// 703348

Testing

This module is thoroughly e2e tested with Jest. Run the with using `npm run test'

Author

Dimitris Lamprinos - @pkakelas