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()
getBlock(hash: string)
Fetches a block given its block hash
const blockHash = '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f'
const latestBlock = infoblock.getBlock(blockHash)
getBlockByHeight(height: number)
Fetches a block given its block height
const firstBlock = await infoblock.getBlockByHeight(0)
getTransaction(txId: string)
Fetches a transaction given its hash
const transactionID = 'a1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d'
const transaction = await infoblock.getTransaction(transactionID)
getUnconfirmedTransactions()
Fetches all unconfirmed transactions
const unconfirmedTransactions = await infoblock.getUnconfirmedTransactions()
getAddress(address: string)
Fetches all details and transactions of a given address
const address = '1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa'
const getAddress = infoblock.getAddress(address)
getDifficulty()
Fetches the current difficulty target
const difficulty = await infoblock.getDifficulty()
getBlockCount()
Fetches the current block height in the longest chain
const count = await infoblock.getBlockCount()
Testing
This module is thoroughly e2e tested with Jest.
Run the with using `npm run test'
Author
Dimitris Lamprinos - @pkakelas