tealcoin-explorer-api
Version:
Module to query blockchain apis for Tealcoin.
86 lines (63 loc) • 2.67 kB
Markdown
Blockchain APIs for Tealcoin Insight Explorer
A module for [Tealcoin Insight Explorer](https://tealcoin-project.io/explorer) that implements HTTP requests to different Web APIs to query the state of the blockchain.
Be careful! When using this module, the information retrieved from remote servers may be compromised and not reflect the actual state of the blockchain.
```sh
npm install tealcoin-explorer-api
```
This API support for both tealcoin and bitcoin blockchain network. You can query both tealcoin and bitcoin blockchain data.
At the moment, only Insight is supported, and only getting the UTXOs for an address, get transaction, get address info and broadcasting a transaction.
```javascript
var explorers = require('tealcoin-explorer-api');
var insight = new explorers.Insight('testnet'); // supported network: livenet,testnet,bitcoin and bitcoin_testnet
insight.getUtxos('tKpkm7WGLWdEaKUU9UCvyb917jE2nxLDCB', function(err, utxos) {
if (err) {
// Handle errors...
} else {
// Maybe use the UTXOs to create a transaction
}
});
```
```javascript
var explorers = require('tealcoin-explorer-api');
var insight = new explorers.Insight('testnet'); // supported network: livenet,testnet,bitcoin and bitcoin_testnet
insight.address('fmLYw2BuhCQ9T1pyJZkYXi8pCq7bAvfN1a', function(err, addrinfo) {
if (err) {
console.log('e:'+err);
} else {
console.log(addrinfo);
}
});
```
```javascript
var explorers = require('tealcoin-explorer-api');
var insight = new explorers.Insight('testnet'); // supported network: livenet,testnet,bitcoin and bitcoin_testnet
insight.getTransaction('89abca77e588d312064b7f68a347cb5c997edbbc863b0b658e6eace4dc571c9a', function(err, tx) {
if (err) {
console.log(err);
} else {
console.log(tx);
}
});
```
```javascript
var explorers = require('tealcoin-explorer-api');
var insight = new explorers.Insight('testnet'); // supported network: livenet,testnet,bitcoin and bitcoin_testnet
var insight = new Insight('testnet');
insight.broadcast(tx, function(err, returnedTxId) {
if (err) {
// Handle errors...
} else {
// Mark the transaction as broadcasted
}
});
```
See [CONTRIBUTING.md](https://github.com/bitpay/bitcore/blob/master/CONTRIBUTING.md) on the main bitcore repo for information about how to contribute.
Code released under [the MIT license](https://github.com/bitpay/bitcore/blob/master/LICENSE).
Copyright 2013-2015 BitPay, Inc. Bitcore is a trademark maintained by BitPay, Inc.
[]: http://github.com/bitpay/bitcore-explorers