Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

whatsonchain

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

whatsonchain - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

18

package.json
{
"name": "whatsonchain",
"version": "0.2.0",
"version": "0.3.0",
"author": {

@@ -16,3 +16,3 @@ "name": "Li Long",

],
"license": "Open BSV",
"license": "MIT",
"main": "index.js",

@@ -32,3 +32,3 @@ "files": [

"dependencies": {
"axios": "^0.21.0",
"axios": "^0.21.4",
"axios-extensions": "^3.1.3"

@@ -38,12 +38,12 @@ },

"chai": "^4.2.0",
"eslint": "^7.12.1",
"eslint-config-standard": "^16.0.1",
"eslint-plugin-mocha": "^8.0.0",
"eslint": "^7.32.0",
"eslint-config-standard": "^16.0.3",
"eslint-plugin-mocha": "^8.2.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.1.1",
"eslint-plugin-standard": "^4.0.2",
"eslint-plugin-promise": "^4.3.1",
"eslint-plugin-standard": "^4.1.0",
"lodash": "^4.17.20",
"mocha": "^8.2.1",
"mocha": "^8.4.0",
"reify": "^0.20.12"
}
}

@@ -10,3 +10,3 @@ # A WhatsOnChain API JS Wrapper library for Bitcoin SV Developer

https://developers.whatsonchain.com/
https://docs.taal.com/core-products/whatsonchain

@@ -27,2 +27,6 @@ ## Install

### 0.3.0
- Move to Taal new document
- Added some new apis
### 0.2.0

@@ -46,2 +50,2 @@ - Support Cache, default is true. if you don't want cache, set option `{ enableCache: false }`

It is released under the terms of the Open BSV license.
It is released under the terms of the MIT license.

@@ -36,8 +36,8 @@ const axios = require( "axios" );

// https://docs.taal.com/core-products/whatsonchain#rate-limits
if ( this._apiKey ) {
headers[ 'woc-api-key' ] = this._apiKey
headers[ 'Authorization' ] = `${this._network === 'main' ? 'mainnet' : this._network === 'test' ? 'testnet' : 'stn'}_${this._apiKey}`
throttleOpt[ 'threshold' ] = 0
} else {
//Up to 3 requests/sec.
// https://developers.whatsonchain.com/#rate-limits
throttleOpt[ 'threshold' ] = 334 //(1000/3)

@@ -104,3 +104,3 @@ }

* Simple endpoint to show API server is up and running
* https://developers.whatsonchain.com/#get-api-status
* https://docs.taal.com/core-products/whatsonchain/health#get-api-status
*/

@@ -115,3 +115,3 @@ status () {

* This endpoint retrieves various state info of the chain for the selected network.
* https://developers.whatsonchain.com/#chain-info
* https://docs.taal.com/core-products/whatsonchain/chain-info#get-blockchain-info
*/

@@ -124,5 +124,23 @@ chainInfo () {

/**
* Get Chain Tips
* This endpoint retrieves information about all known tips in the block tree.
* https://docs.taal.com/core-products/whatsonchain/chain-info#get-chain-tips
*/
chainTips () {
return this._get( 'chain/tips' )
}
/**
* Get Peer Info
* This endpoint retrieves information on peers connected to the node.
* https://docs.taal.com/core-products/whatsonchain/chain-info#get-chain-tips
*/
peerInfo () {
return this._get( 'peer/info' )
}
/**
* Get Circulating Supply
* This endpoint provides circulating supply of BSV.
* https://developers.whatsonchain.com/#get-circulating-supply
* https://docs.taal.com/core-products/whatsonchain/chain-info#get-circulating-supply
*/

@@ -134,7 +152,6 @@ circulatingsupply () {

/**
* Get by hash
* This endpoint retrieves block details with given hash.
* https://developers.whatsonchain.com/#get-by-hash
* https://docs.taal.com/core-products/whatsonchain/block#get-by-hash
* @param {string} hash The hash of the block to retrieve

@@ -149,3 +166,3 @@ */

* This endpoint retrieves block details with given block height.
* https://developers.whatsonchain.com/#get-by-height
* https://docs.taal.com/core-products/whatsonchain/block#get-by-height
* @param {number} height The height of the block to retrieve

@@ -161,3 +178,3 @@ */

* If the block has more that 1000 transactions the page URIs will be provided in the pages element when getting a block by hash or height.
* https://developers.whatsonchain.com/#get-block-pages
* https://docs.taal.com/core-products/whatsonchain/block#get-block-pages
* @param {string} hash The hash of the block to retrieve

@@ -173,3 +190,3 @@ * @param {number} page Page number

* This endpoint retrieves block header details with given hash.
* https://developers.whatsonchain.com/#get-header-by-hash
* https://docs.taal.com/core-products/whatsonchain/block#get-header-by-hash
* @param {string} hash The hash of the block to retrieve

@@ -184,2 +201,3 @@ */

* This endpoint retrieves last 10 block headers.
* https://docs.taal.com/core-products/whatsonchain/block#get-headers
*/

@@ -190,9 +208,31 @@ blockHeaders () {

/**
* Get Header Bytes File Links
* This endpoint retrieves a list of block header binary file links
* and each file only contains 80-byte block headers.
* These contain 10,000 block headers per file up to height 760,000.
* https://docs.taal.com/core-products/whatsonchain/block#get-headers
*/
blockHeadersResources () {
return this._get( 'block/headers/resources' )
}
/**
* Get Latest Header Bytes
* This endpoint retrieves the latest specified number of block headers (up to 100)
* as a binary file. If "count" parameter is not provided,
* returns the latest header file, with up to 2000 block headers.
* https://docs.taal.com/core-products/whatsonchain/block#get-headers
*/
blockHeadersLatestCount ( count ) {
return this._get( 'block/headers/latest', { count } )
}
/**
* Get by tx hash
* This endpoint retrieves transaction details with given transaction hash.
* In the response body, if any output hex size, exceeds 100KB then data is truncated
* NOTICE:A separate endpoint get raw transaction output data can be used to fetch full hex data
* https://developers.whatsonchain.com/#get-by-tx-hash
* This endpoint retrieves the transaction details for a given transaction hash.
* In the response body, if any output's hex size (vout[x].scriptPubKey.hex) exceeds 100KB,
* then the data for vout[x].scriptPubKey.hex and vout[x].scriptPubKey.asm is truncated
* and a flag vout[x].scriptPubKey.isTruncated is set to true.
* https://docs.taal.com/core-products/whatsonchain/transaction#get-by-tx-hash
* @param {string} hash The hash/txId of the transaction to retrieve

@@ -205,5 +245,17 @@ */

/**
* Get Transaction Propagation Status
* This endpoint returns the propagation status for a given transaction.
* It queries a random set of peers on the network and returns
* the number of peers that have the transaction in question.
* https://docs.taal.com/core-products/whatsonchain/transaction#get-transaction-propagation-status
* @param {string} hash The hash/txId of the transaction to retrieve
*/
txHashByPropagation ( hash ) {
return this._get( `tx/hash/${hash}/propagation` )
}
/**
* Broadcast transaction
* Broadcast transaction using this endpoint. Get txid in response or error msg from node with header content-type: text/plain.
* https://developers.whatsonchain.com/#broadcast-transaction
* https://docs.taal.com/core-products/whatsonchain/transaction#broadcast-transaction
* @param {string} txhex Raw transaction data in hex

@@ -218,22 +270,6 @@ */

/**
* Bulk Broadcast
* https://developers.whatsonchain.com/#bulk-broadcast
* - Size per transaction should be less than 100KB
* - Overall payload per request should be less than 10MB
* - Max 100 transactions per request
* - Only available for mainnet
* https://developers.whatsonchain.com/#bulk-broadcast
* @param {Array} txhexArray
* @param {boolean} feedback
*/
bulkBroadcast ( txhexArray, feedback = false ) {
return this._post( `tx/broadcast?feedback=${feedback}`, txhexArray )
}
/**
* Bulk transaction details
* Fetch details for multiple transactions in single request
* - Max 20 transactions per request
* https://developers.whatsonchain.com/#bulk-transaction-details
* https://docs.taal.com/core-products/whatsonchain/transaction#bulk-transaction-details
* @param {Array} txidArray

@@ -248,2 +284,15 @@ */

/**
* Bulk Transaction Status
* You can get the status of multiple transactions in a single request.
* - Max 20 transactions per request
* https://docs.taal.com/core-products/whatsonchain/transaction#bulk-transaction-status
* @param {Array} txidArray
*/
bulkTxDetails ( txidArray ) {
return this._post( `txs/status`, {
txids: txidArray
} )
}
/**
* Decode transaction

@@ -262,15 +311,5 @@ * Decode raw transaction using this endpoint. Get json in response or error msg from node.

/**
* Download receipt
* Download transaction receipt (PDF)
* https://developers.whatsonchain.com/#download-receipt
* @param {string} hash The hash/txId of the transaction
*/
receiptPDF ( hash ) {
return this._get( `https://${this._network}.whatsonchain.com/receipt/${hash}` )
}
/**
* Get raw transaction data
* Get raw transaction data in hex
* https://developers.whatsonchain.com/#get-raw-transaction-data
* https://docs.taal.com/core-products/whatsonchain/transaction#get-raw-transaction-data
* @param {string} hash The hash/txId of the transaction

@@ -282,2 +321,14 @@ */

/**
* Bulk Raw Transaction Data
* You can get the raw data of multiple transactions in hex in a single request.
* - Max 20 transactions per request
* https://docs.taal.com/core-products/whatsonchain/transaction#bulk-raw-transaction-data
* @param {Array} txidArray
*/
bulkTxData ( txidArray ) {
return this._post( `txs/hex`, {
txids: txidArray
} )
}

@@ -287,3 +338,3 @@ /**

* Get raw transaction vout data in hex
* https://developers.whatsonchain.com/#get-raw-transaction-output-data
* https://docs.taal.com/core-products/whatsonchain/transaction#get-raw-transaction-output-data
* @param {string} hash The hash/txId of the transaction

@@ -300,3 +351,3 @@ * @param {number} outputIndex Output index

* This endpoint returns merkle branch to a confirmed transaction
* https://developers.whatsonchain.com/#get-merkle-proof
* https://docs.taal.com/core-products/whatsonchain/transaction#get-merkle-proof
* @param {string} hash The hash/txId of the transaction

@@ -312,3 +363,3 @@ */

* This endpoint retrieves various info about the node's mempool for the selected network.
* https://developers.whatsonchain.com/#get-mempool-info
* https://docs.taal.com/core-products/whatsonchain/mempool#get-mempool-info
*/

@@ -323,3 +374,3 @@ mempoolInfo () {

* This endpoint retrieve list of transaction ids from the node's mempool for the selected network.
* https://developers.whatsonchain.com/#get-mempool-transactions
* https://docs.taal.com/core-products/whatsonchain/mempool#get-mempool-transactions
*

@@ -335,2 +386,3 @@ */

* This endpoint retrieves various address info.
* https://docs.taal.com/core-products/whatsonchain/address#get-address-info
* @param {string} address

@@ -343,4 +395,15 @@ */

/**
* Get Address Usage Status
* This endpoint serves as a usage status flag for a given address.
* https://docs.taal.com/core-products/whatsonchain/address#get-address-usage-status
* @param {string} address
*/
addressUsed ( address ) {
return this._get( `address/${address}/used` )
}
/**
* Get balance
* This endpoint retrieves confirmed and unconfirmed address balance.
* https://docs.taal.com/core-products/whatsonchain/address#get-balance
* @param {string} address

@@ -353,5 +416,19 @@ */

/**
* Bulk Balance
* This endpoint retrieves both the confirmed and unconfirmed balance for
* multiple addresses in a single request.
* Max 20 addresses per request.
* https://docs.taal.com/core-products/whatsonchain/address#bulk-balance
* @param {Array<string>} addressArray
*/
bulkBalance ( addressArray ) {
return this._post( `address/balance`, {
addresses: addressArray
} )
}
/**
* Get history
* This endpoint retrieves confirmed and unconfirmed address transactions.
* https://developers.whatsonchain.com/#get-history
* https://docs.taal.com/core-products/whatsonchain/address#get-history
* @param {string} address

@@ -365,4 +442,4 @@ */

* Get unspent transactions
* This endpoint retrieves ordered list of UTXOs.
* https://developers.whatsonchain.com/#get-unspent-transactions
* This endpoint retrieves an ordered list of UTXOs for a given address.
* https://docs.taal.com/core-products/whatsonchain/address#get-unspent-transactions
* @param {string} address

@@ -374,2 +451,14 @@ */

/**
* Bulk Unspent Transactions
* This endpoint retrieves a list of UTXOs for multiple addresses in a single request.
* Max 20 addresses per request.
* https://docs.taal.com/core-products/whatsonchain/address#bulk-unspent-transactions
* @param {Array<string>} addressArray
*/
bulkUtxos ( addressArray ) {
return this._post( `address/unspent`, {
addresses: addressArray
} )
}

@@ -379,3 +468,3 @@ /**

* Download address statement (PDF)
* https://developers.whatsonchain.com/#download-statement
* https://docs.taal.com/core-products/whatsonchain/address#download-statement
* @param {string} address

@@ -388,7 +477,17 @@ */

/**
* Get Script Usage Status
* This endpoint serves as a usage status flag for a given script.
* https://docs.taal.com/core-products/whatsonchain/script#get-script-usage-status
* @param {string} address
*/
scriptUsed ( scriptHash ) {
return this._get( `script/${scriptHash}/used` )
}
/**
* Get script history
* This endpoint retrieves confirmed and unconfirmed script transactions.
* https://developers.whatsonchain.com/#script
* https://docs.taal.com/core-products/whatsonchain/script#get-script-history
* @param {string} scriptHash Script hash: Sha256 hash of the binary bytes of the locking script (ScriptPubKey), expressed as a hexadecimal string.

@@ -403,3 +502,3 @@ */

* This endpoint retrieves ordered list of UTXOs.
* https://developers.whatsonchain.com/#get-script-unspent-transactions
* https://docs.taal.com/core-products/whatsonchain/script#get-script-unspent-transactions
* @param {string} scriptHash Script hash: Sha256 hash of the binary bytes of the locking script (ScriptPubKey), expressed as a hexadecimal string.

@@ -412,5 +511,18 @@ */

/**
* Bulk Script Unspent Transactions
* This endpoint retrieves a list of UTXOs for multiple addresses in a single request.
* Max 20 addresses per request.
* https://docs.taal.com/core-products/whatsonchain/address#bulk-unspent-transactions
* @param {Array<string>} addressArray
*/
bulkUtxosByScriptHash ( scriptHashArray ) {
return this._post( `scripts/unspent`, {
scripts: scriptHashArray
} )
}
/**
* Get exchange rate
* This endpoint provides exchange rate for BSV.
* https://developers.whatsonchain.com/#exchange-rate
* https://docs.taal.com/core-products/whatsonchain/exchange-rate#get-exchange-rate
*/

@@ -421,37 +533,29 @@ exchangeRate () {

/**
* Fee quotes
* This endpoint provides fee quotes from multiple transaction processors. Each quote also contains transaction processor specific txSubmissionUrl and txStatusUrl. These unique URLs can be used to submit transactions to the selected transaction processor and check the status of the submitted transaction.
* https://developers.whatsonchain.com/#merchant-api-beta
* Get Historical Exchange Rate
* This endpoint provides the historical exchange rate data for BSV. Exchange rate data goes back to 2018/11/19.
* https://docs.taal.com/core-products/whatsonchain/exchange-rate#get-historical-exchange-rate
*
* @param {*} [from] unixtimestamp
* @param {*} [to] unixtimestamp
*
*/
feeQuotes () {
return this._get( `https://api.whatsonchain.com/v1/bsv/main/mapi/feeQuotes` )
}
/**
* Submit transaction
* Submit a transaction to a specific transaction processor using the txSubmissionUrl provided with each quote in the Fee quotes response.
* https://developers.whatsonchain.com/#submit-transaction
* @param {string} providerId Unique providerId from the Fee quotes response
* @param {string} rawtx Raw transaction data in hex
*/
submitTx ( providerId, rawtx ) {
return this._post( `mapi/${providerId}/tx`, {
rawtx
exchangeRate ( from, to ) {
return this._get( `exchangerate/historical`, {
from, to
} )
}
/**
* Transaction status
* Get a transaction's status from a specific transaction processor using the txStatusUrl provided with each quote in Fee quotes response.
* @param {string} providerId Unique providerId from the Fee quotes response
* @param {string} hash The hash/txId of the transaction
*/
txStatus ( providerId, hash ) {
return this._get( `mapi/${providerId}/tx/${hash}` )
* Get OP_RETURN Data by Tx Hash
* This endpoint returns OP_RETURN data as hex for each output in the transaction.
* https://docs.taal.com/core-products/whatsonchain/on-chain-data#get-op_return-data-by-tx-hash
*
* @param {*} [hash] The desired TX hash.
*
*/
GetOPReturnByTxHash ( hash ) {
return this._get( `tx/${hash}/opreturn` )
}
/**

@@ -468,4 +572,59 @@ * Get explorer links

}
/**
* Get Block Stats by Height
* This endpoint retrieves the block stats for a given height.
* Exchange rate information is not available for blocks processed before 2018/11/19.
* Unidentified block miners are tagged as an empty string.
* https://docs.taal.com/core-products/whatsonchain/stats#get-block-stats-by-height
*
* @param {*} [height] The height of the block to retrieve.
*
*/
blockHeightStats ( height ) {
return this._get( `block/height/${height}/stats` )
}
/**
* Get Block Stats by Hash
* This endpoint retrieves the block stats for a given hash.
* Exchange rate information is not available for blocks processed before 2018/11/19.
* Unidentified block miners are tagged as an empty string.
* https://docs.taal.com/core-products/whatsonchain/stats#get-block-stats-by-hash
*
* @param {*} [hash] The hash of the block to retrieve.
*
*/
blockHashStats ( hash ) {
return this._get( `block/hash/${hash}/stats` )
}
/**
* Get Miner Block Stats
* This endpoint retrieves the miner block stats for specified days.
* Unidentified block miners are tagged as an empty string.
* https://docs.taal.com/core-products/whatsonchain/stats#get-miner-block-stats
*
* @param {*} [days] The number of days to retrieve the data for. Only 1 or 30 days can be selected.
*
*/
minerBlocksStats ( days ) {
return this._get( `miner/blocks/stats`, { days } )
}
/**
* Get Miner Summary Stats
* This endpoint retrieves the miner summary stats for specified days over a 24 hour period.
* Unidentified block miners are tagged as an empty string.
* https://docs.taal.com/core-products/whatsonchain/stats#get-miner-summary-stats
*
* @param {*} [days] The number of days to retrieve the data for. Only 1 or 30 days can be selected.
*
*/
minerSummaryStats ( days ) {
return this._get( `miner/summary/stats`, { days } )
}
}
module.exports = WhatsOnChain
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc