beyondcore-explorers
Module to query blockchain apis for Beyondcore.
Last updated 10 months ago by tech1k .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install beyondcore-explorers 
SYNC missed versions from official npm registry.

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.

Current Tags

  • 1.0.0                                ...           latest (10 months ago)

1 Versions

  • 1.0.0                                ...           10 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (3)
Dev Dependencies (6)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |