beyondcore-explorers

1.0.0 • Public • Published

Blockchain APIs for Beyondcore

NPM Package

A module for Beyondcore that implements HTTP requests to different Web APIs to query the state of the blockchain.

Getting started

Be careful! When using this module, the information retrieved from remote servers may be compromised and not reflect the actual state of the blockchain.

npm install beyondcore-explorers
bower install beyondcore-explorers

UTXOs

var explorers = require('beyondcore-explorers');
var insight = new explorers.Insight();
 
insight.getUtxos('mBeyondcoin...', function(err, utxos) {
  if (err) {
    // Handle errors...
  } else {
    // Maybe use the UTXOs to create a transaction
  }
});

You can optionally pass a minimum confirmation amount, and getUtxos will only return unspent transactions with at least that many confirmations.

var explorers = require('beyondcore-explorers');
var insight = new explorers.Insight();
 
insight.getUtxos({address: 'mBeyondcoin...', minconf: 5}, function(err, utxos) {
  if (err) {
    // Handle errors...
  } else {
    // UTXOs with at least 5 confirmations are here
  }
});

Address

Get information about a Beyondcoin address:

var explorers = require('beyondcore-explorers');
var insight = new explorers.Insight();
 
insight.address('mBeyondcoin...', function(err, data) {
  if (err) {
    // Handle errors...
  } else {
    // Address information here
  }
});

You can also specify a "from" and "to" range, useful for paging through the transaction history of an address:

var explorers = require('beyondcore-explorers');
var insight = new explorers.Insight();
 
insight.address({address: 'mBeyondcoin...', from: 1000, to: 2000}, function(err, data) {
  if (err) {
    // Handle errors...
  } else {
    // Address information here
  }
});

Blocks

Get information about recent blocks:

var explorers = require('beyondcore-explorers');
var insight = new explorers.Insight();
 
insight.getBlocks(function(err, blocks) {
  if (err) {
    // Handle errors...
  } else {
    //Recent block data here
  }
});

Get information about a specific block, by its blockhash:

var explorers = require('beyondcore-explorers');
var insight = new explorers.Insight();
 
insight.getBlock('369005760377532901c126ae4e907352f66624033275c92803f538773415792a', function(err, block) {
  if (err) {
    // Handle errors...
  } else {
    //Block data here
  }
});

Broadcast a Transaction

var explorers = require('beyondcore-explorers');
var insight = new explorers.Insight();
 
insight.broadcast(tx, function(err, returnedTxId) {
  if (err) {
    // Handle errors...
  } else {
    // Mark the transaction as broadcasted
  }
});

License

Code released under the MIT license.

Package Sidebar

Install

npm i beyondcore-explorers

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

59 kB

Total Files

19

Last publish

Collaborators

  • tech1k