0.4.3 • Published 6 years ago

blockchain-api-basic v0.4.3

Weekly downloads
9
License
ISC
Repository
-
Last release
6 years ago

Simple API around Blockchain.info to: get address balance, get UTXOs, and push transactions.

Install

npm i --save blockchain-api-basic

Usage

Require the api:

const bcApi   = require('blockchain-api-basic')
const balance = bcApi.balance
const utxos   = bcApi.utxos
const pushTx  = bcApi.pushTx
  • balance(address)

Retreives the balance of a given address

;(async () => {
  const bal = await balance(address)
  console.log("balance:", bal)
  // => balance: 9754600 (satoshis)
})()
  • utxos(address)

Retrieves all the unspent transaction outputs for a given address:

const outputs = await utxos(address)
console.log("UTXOs:", outputs)
// => UTXOs: [ { tx_hash: ... }, {...} ]

(note I'm omitting async from this example)

  • pushTx(tx_hash)
const rawTX = "...." // your raw tx - for example you can create a transaction by using bitcoinjslib or bitcore and then serialize the transaction to get the raw tx in hex format
const response = await pushtx(rawTX)
console.log("push tx response:", response)

Enjoy!

@makevoid

0.4.3

6 years ago

0.4.2

6 years ago

0.4.1

6 years ago

0.4.0

6 years ago

0.3.3

7 years ago

0.3.2

7 years ago

0.3.0

7 years ago

0.2.3

10 years ago

0.2.2

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago