v2.2.0 - new major version for mempool-js (#2)
* - Refactoring code. - Refactoring folder structure. - Adding apiEndpoint and websocketEndpoint to Mempool config. - Adding brownserify feature. - Adding MIT LICENSE * - Changing package.json information. - Reorganizing README.md information. - Default export for CommonJs and ES6 Modules. - Changing default variable to mempoolJS. - Organizing the API and WS providers. - Splitting websocket connection types: client and server. * Change version to 2.2.0. Reorder keywords in alphabetical order.
This commit is contained in:
23
examples/nodejs/addresses.ts
Normal file
23
examples/nodejs/addresses.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import mempoolJS from '../../src/index';
|
||||
|
||||
const init = async () => {
|
||||
const { addresses } = mempoolJS();
|
||||
|
||||
const address = '1wizSAYSbuyXbt9d8JV8ytm5acqq2TorC';
|
||||
|
||||
const addressTest = await addresses.getAddress(address);
|
||||
console.log(addressTest);
|
||||
|
||||
const addressTxs = await addresses.getAddressTxs(address);
|
||||
console.log(addressTxs);
|
||||
|
||||
const addressTxsChain = await addresses.getAddressTxsChain(address);
|
||||
console.log(addressTxsChain);
|
||||
|
||||
const addressTxsMempool = await addresses.getAddressTxsMempool(address);
|
||||
console.log(addressTxsMempool);
|
||||
|
||||
const addressTxsUtxo = await addresses.getAddressTxsUtxo(address);
|
||||
console.log(addressTxsUtxo);
|
||||
};
|
||||
init();
|
||||
39
examples/nodejs/blocks.ts
Normal file
39
examples/nodejs/blocks.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import mempoolJS from '../../src/index';
|
||||
|
||||
const init = async () => {
|
||||
const { blocks } = mempoolJS();
|
||||
|
||||
const hash =
|
||||
'000000000000000015dc777b3ff2611091336355d3f0ee9766a2cf3be8e4b1ce';
|
||||
|
||||
const block = await blocks.getBlock(hash);
|
||||
console.log(block);
|
||||
|
||||
const blockStatus = await blocks.getBlockStatus(hash);
|
||||
console.log(blockStatus);
|
||||
|
||||
const blockTxs = await blocks.getBlockTxs({ hash });
|
||||
console.log(blockTxs);
|
||||
|
||||
const blockTxids = await blocks.getBlockTxids(hash);
|
||||
console.log(blockTxids);
|
||||
|
||||
const blockTxid = await blocks.getBlockTxid({ hash, index: 218 });
|
||||
console.log(blockTxid);
|
||||
|
||||
const blockRaw = await blocks.getBlockRaw(hash);
|
||||
console.log(blockRaw);
|
||||
|
||||
const blockHeight = await blocks.getBlockHeight(9999);
|
||||
console.log(blockHeight);
|
||||
|
||||
const getBlocks = await blocks.getBlocks({ start_height: 9999 });
|
||||
console.log(getBlocks);
|
||||
|
||||
const blocksTipHeight = await blocks.getBlocksTipHeight();
|
||||
console.log(blocksTipHeight);
|
||||
|
||||
const blocksTipHash = await blocks.getBlocksTipHash();
|
||||
console.log(blocksTipHash);
|
||||
};
|
||||
init();
|
||||
12
examples/nodejs/fees.ts
Normal file
12
examples/nodejs/fees.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import mempoolJS from '../../src/index';
|
||||
|
||||
const init = async () => {
|
||||
const { fees } = mempoolJS();
|
||||
|
||||
const feesRecommended = await fees.getFeesRecommended();
|
||||
console.log(feesRecommended);
|
||||
|
||||
const feesMempoolBlocks = await fees.getFeesMempoolBlocks();
|
||||
console.log(feesMempoolBlocks);
|
||||
};
|
||||
init();
|
||||
15
examples/nodejs/mempool.ts
Normal file
15
examples/nodejs/mempool.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import mempoolJS from '../../src/index';
|
||||
|
||||
const init = async () => {
|
||||
const { mempool } = mempoolJS();
|
||||
|
||||
const getMempool = await mempool.getMempool();
|
||||
console.log(getMempool);
|
||||
|
||||
const getMempoolRecent = await mempool.getMempoolRecent();
|
||||
console.log(getMempoolRecent);
|
||||
|
||||
const getMempoolTxids = await mempool.getMempoolTxids();
|
||||
console.log(getMempoolTxids);
|
||||
};
|
||||
init();
|
||||
39
examples/nodejs/transactions.ts
Normal file
39
examples/nodejs/transactions.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import mempoolJS from '../../src/index';
|
||||
|
||||
const init = async () => {
|
||||
const { transactions } = mempoolJS();
|
||||
|
||||
const txid =
|
||||
'15e10745f15593a899cef391191bdd3d7c12412cc4696b7bcb669d0feadc8521';
|
||||
|
||||
const tx = await transactions.getTx(txid);
|
||||
console.log(tx);
|
||||
|
||||
const txStatus = await transactions.getTxStatus(txid);
|
||||
console.log(txStatus);
|
||||
|
||||
const txHex = await transactions.getTxHex(txid);
|
||||
console.log(txHex);
|
||||
|
||||
const txRaw = await transactions.getTxRaw(txid);
|
||||
console.log(txRaw);
|
||||
|
||||
const txMerkleBlockProof = await transactions.getTxMerkleBlockProof(txid);
|
||||
console.log(txMerkleBlockProof);
|
||||
|
||||
const txMerkleProof = await transactions.getTxMerkleProof(txid);
|
||||
console.log(txMerkleProof);
|
||||
|
||||
const txOutspend = await transactions.getTxOutspend({
|
||||
txid,
|
||||
vout: 3,
|
||||
});
|
||||
console.log(txOutspend);
|
||||
|
||||
const txOutspends = await transactions.getTxOutspends(txid);
|
||||
console.log(txOutspends);
|
||||
|
||||
// const postTx = await transactions.postTx(txid);
|
||||
// console.log(postTx);
|
||||
};
|
||||
init();
|
||||
29
examples/nodejs/websocket.ts
Normal file
29
examples/nodejs/websocket.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import mempoolJS from '../../src/index';
|
||||
|
||||
const init = async () => {
|
||||
const { websocket } = mempoolJS();
|
||||
|
||||
const ws = websocket.initServer({
|
||||
options: ['blocks', 'stats', 'mempool-blocks', 'live-2h-chart'],
|
||||
});
|
||||
|
||||
ws.on('message', function incoming(data) {
|
||||
const res = JSON.parse(data.toString());
|
||||
if (res.blocks) {
|
||||
res.blocks.forEach((block: { height: any }) => {
|
||||
console.log(block.height);
|
||||
});
|
||||
}
|
||||
if (res.mempoolInfo) {
|
||||
console.log(res.mempoolInfo);
|
||||
}
|
||||
if (res.transactions) {
|
||||
console.log(res.transactions);
|
||||
}
|
||||
if (res.mempoolBlocks) {
|
||||
console.log(res.mempoolBlocks);
|
||||
}
|
||||
});
|
||||
};
|
||||
init();
|
||||
Reference in New Issue
Block a user