diff --git a/README-bitcoin.md b/README-bitcoin.md index 9b8d30340..f7d87a211 100644 --- a/README-bitcoin.md +++ b/README-bitcoin.md @@ -31,6 +31,8 @@ Interface to access the Bitcoin `mainet`, `testnet`, `signet` APIs. - [Get Blocks](#get-blocks) - [Get Blocks Tip Height](#get-blocks-tip-height) - [Get Blocks Tip Hash](#get-blocks-tip-hash) + - Difficulty + - [Get Difficulty Adjustment](#get-difficulty-adjustment) - Fees - [Get Fees Recommended](#get-fees-recommended) - [Get Fees Mempool Blocks](#get-fees-mempool-blocks) @@ -376,6 +378,21 @@ const blocksTipHash = await blocks.getBlocksTipHash(); console.log(blocksTipHash); ``` +### **Get Difficulty Adjustment** + +Returns the hash of the last block. + +[ [NodeJS Example](examples/nodejs/bitcoin/difficulty.ts) ] [ [HTML Example](examples/html/bitcoin/difficulty.html) ] [ [Top](#features) ] + +```js +const { + bitcoin: { difficulty }, +} = mempoolJS(); + +const difficultyAdjustment = await difficulty.getDifficultyAdjustment(); +console.log(difficultyAdjustment); +``` + ### **Get Fees Recommended** Returns our currently suggested fees for new transactions. diff --git a/examples/html/bitcoin/difficulty.html b/examples/html/bitcoin/difficulty.html new file mode 100644 index 000000000..4b13d106c --- /dev/null +++ b/examples/html/bitcoin/difficulty.html @@ -0,0 +1,20 @@ + + + + Page Title + + + + + diff --git a/examples/nodejs/bitcoin/difficulty.ts b/examples/nodejs/bitcoin/difficulty.ts new file mode 100644 index 000000000..3f5a9feeb --- /dev/null +++ b/examples/nodejs/bitcoin/difficulty.ts @@ -0,0 +1,11 @@ +import mempoolJS from "@mempool/mempool.js"; + +const init = async () => { + const { + bitcoin: { difficulty }, + } = mempoolJS(); + + const difficultyAdjustment = await difficulty.getDifficultyAdjustment(); + console.log(difficultyAdjustment); +}; +init();