Blockinfo
A typescript module for interacting with the blockchain.info.
Installation
npm install blockchainfo
API
Initialization
const Blockchainfo = require('blockchainfo')
const client = new Blockchainfo()
Methods
getLatestBlock()
Fetches the latest block
const latestBlock = client.getLatestBlock()
getBlock(hash: string)
Fetches a block given its block hash
const blockHash = '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f'
const latestBlock = client.getBlock(blockhash)
getBlock(hash: string)
Fetches a block given its height
const firstBlock = await client.getBlockByHeight(0)
getTransaction()
const transactionID = 'a1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d'
const transaction = await client.getTransaction(transactionID)
getUnconfirmedTransactions
const unconfirmedTransactions = await client.getUnconfirmedTransactions()
getAddress()
const address = '1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa'
const getAddress = client.getAddress(address)
getDifficulty()
const difficulty = await client.getDifficulty()
getBlockCount
const count = await client.getBlockCount()
Testing
This module is thoroughly e2e tested with jest.
Run the with using `npm run test'
Author
Dimitris Lamprinos - @pkakelas