Bitails Explorer API Wrapper

Quickstart Guide


Setup

			

or

			
npm i git+https://github.com/untrusting/bitails

Initialization

			
// Mainnet const explorer = new Explorer("main"); // Testnet const explorer = new Explorer("test");
				status()

				chainInfo()

				blockHash()

				blockHeight()

				blockList(height, limit)

				blockLatest(hash)

				blockTransactions(hash)

				txHash(hash)

				downloadTx(hash)
				
				downloadTxOut(hash, index)

				getOutputData(hash, indices)

				getOutputsData(hash, fromIndex, toIndex)

				broadcast(txhex)

				broadcastBinary(txBuf)

				merkleProof(hash)

				mempoolInfo()

				mempoolTxs()

				addressInfo(address)

				balance(address)

				history(address)

				utxos(address)

				detailScriptHash(scriptHash)

				balanceScriptHash(scriptHash)

				historyByScriptHash(scriptHash)

				utxosByScriptHash(scriptHash)

				search(text)
			

Network Status

explorer.status()

			
let stats = explorer.status().then((state) => { console.log("Network Status"); console.table(state); document.getElementById("networkStatus").innerText = JSON.stringify(state, null, '\t'); });

Response:


Network Information

explorer.chainInfo()

			
let stats = explorer.chainInfo().then((info) => { console.log("Network Information"); console.table(info); document.getElementById("networkInfo").innerText = JSON.stringify(info, null, '\t'); });

Response:


Block by Hash

explorer.blockHash(hash)

			
explorer.blockHash("00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048").then((block) => { console.log("Block Hash:", block.hash); console.table(block); document.getElementById("blockByHash").innerText = JSON.stringify(block, null, '\t'); });

Response:


Block at Height

explorer.blockHeight(heightNumber)

			
explorer.blockHeight(0).then((genesis) => { console.log("Genesis Block Hash:", genesis.hash); console.table(genesis); document.getElementById("genesis").innerText = JSON.stringify(genesis, null, '\t'); });

Response:


Block List

explorer.blockList(height, limit)

			
explorer.blockList(0, 10).then((blockList) => { console.log(blockList); document.getElementById("blockList").innerText = JSON.stringify(blockList, null, '\t'); });

Response:


Latest Block

explorer.blockLatest()

			
explorer.blockLatest().then((latest) => { console.log("Latest block:", latest.hash); console.log("Number of transactions: ", latest.transactionsDetails.length); document.getElementById("latest").innerText = JSON.stringify(latest, null, '\t'); console.table(latest); });

Response:


Transactions in a Block

explorer.blockTransactions(hash)

			
explorer.blockTransactions("00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048").then((transactionList) => { console.log(transactionList); document.getElementById("transactionList").innerText = JSON.stringify(transactionList, null, '\t'); });

Response:


Transaction Details

explorer.txHash(txid)

			
explorer.txHash("0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098").then((txData) => { console.log(txData); document.getElementById("txData").innerText = JSON.stringify(txData, null, '\t'); });

Response:


Download a Transaction

explorer.downloadTx(txid)

			
explorer.downloadTx("0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098").then((allTxData) => { console.log(allTxData); document.getElementById("allTxData").innerText = JSON.stringify(allTxData, null, '\t'); });

Response:


Download a Transaction Output

explorer.downloadTxOut(txid, indice)

			
explorer.downloadTxOut("d4c7a2310684e52d7fe6fec3e0083fe9a6c0decfe13be2598abf61903c6c3de3", 0).then((txOut) => { console.log(txOut); document.getElementById("TxOut").innerText = JSON.stringify(txOut, null, '\t'); });

Response:


Get Data from a Transaction Output

explorer.getOutputData(txid, indice)

			
explorer.getOutputData("d4c7a2310684e52d7fe6fec3e0083fe9a6c0decfe13be2598abf61903c6c3de3", 0).then((txOutData) => { console.log(txOutData); document.getElementById("txOutData").innerText = JSON.stringify(txOutData, null, '\t'); });

Response:


Get Data from Multiple Transaction Outputs

explorer.getOutputsData(txid, fromIndex, toIndex)

			
explorer.getOutputsData("d4c7a2310684e52d7fe6fec3e0083fe9a6c0decfe13be2598abf61903c6c3de3", 0,3).then((txOutputsData) => { console.log(txOutputsData); document.getElementById("txOutputsData").innerText = JSON.stringify(txOutputsData, null, '\t'); });

Response:


Broadcast

explorer.broadcast(txHex)

			
explorer.broadcast(txHex).then((res) => { console.log(res); });

Broadcast Binary

explorer.broadcastBinary(txBuf)

			
explorer.broadcastBinary(txBuf).then((res) => { console.log(res); });

Merkle Proof of a Transaction

explorer.merkleProof(txid)

			
explorer.merkleProof("0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098").then((merkleProof) => { console.log(merkleProof); document.getElementById("merkleProof").innerText = JSON.stringify(merkleProof, null, '\t'); });

Response:


Mempool Information

explorer.mempoolInfo()

			
explorer.mempoolInfo().then((memInfo) => { console.log(memInfo); document.getElementById("memInfo").innerText = JSON.stringify(memInfo, null, '\t'); });

Response:


Mempool Transactions

explorer.mempoolTxs()

			
explorer.mempoolTxs().then((memTxs) => { console.log(memTxs); document.getElementById("memTxs").innerText = JSON.stringify(memTxs, null, '\t'); });

Response:


Address Information

explorer.addressInfo(address)

			
explorer.addressInfo(address).then((addrInfo) => { console.log(addrInfo); document.getElementById("addrInfo").innerText = JSON.stringify(addrInfo, null, '\t'); });

Response:


Address Balance

explorer.balance(address)

			
explorer.addressInfo(address).then((balance) => { console.log(balance); document.getElementById("balance").innerText = JSON.stringify(balance, null, '\t'); });

Response:


Address History

explorer.history(address)

			
explorer.history(address).then((historial) => { console.log(historial); document.getElementById("historial").innerText = JSON.stringify(historial, null, '\t'); });

Response:


Address UTXOs

explorer.utxos(address)

			
explorer.utxos(address).then((historial) => { console.log(utxos); document.getElementById("utxos").innerText = JSON.stringify(utxos, null, '\t'); });

Response:


ScriptHash Details

explorer.detailsScriptHash(scriptHash)

			
explorer.detailsScriptHash(scriptHash).then((detailsScriptHash) => { console.log(detailsScriptHash); document.getElementById("detailsScriptHash").innerText = JSON.stringify(detailsScriptHash, null, '\t'); });

Response:


Balance of ScriptHash

explorer.balanceScriptHash(scriptHash)

			
explorer.balanceScriptHash(scriptHash).then((balanceScriptHash) => { console.log(balanceScriptHash); document.getElementById("balanceScriptHash").innerText = JSON.stringify(balanceScriptHash, null, '\t'); });

Response:


ScriptHash History

explorer.historyByScriptHash(scriptHash)

			
explorer.historyByScriptHash(scriptHash).then((historialScriptHash) => { console.log(historialScriptHash); document.getElementById("historialScriptHash").innerText = JSON.stringify(historialScriptHash, null, '\t'); });

Response:


UTXOs by ScriptHash

explorer.utxosByScriptHash(scriptHash)

			
explorer.utxosByScriptHash(scriptHash).then((utxosByScriptHash) => { console.log(utxosByScriptHash); document.getElementById("utxosByScriptHash").innerText = JSON.stringify(utxosByScriptHash, null, '\t'); });

Response:


Search Blockchain

explorer.search(query)

			
explorer.search("hello,world").then((ops) => { console.log(ops); document.getElementById("balanceScriptHash").innerText = JSON.stringify(ops.results, null, '\t'); });

Response: