Add difficulty adjustment examples.
This commit is contained in:
parent
caf8d956b5
commit
aed4bc5fc9
@ -31,6 +31,8 @@ Interface to access the Bitcoin `mainet`, `testnet`, `signet` APIs.
|
|||||||
- [Get Blocks](#get-blocks)
|
- [Get Blocks](#get-blocks)
|
||||||
- [Get Blocks Tip Height](#get-blocks-tip-height)
|
- [Get Blocks Tip Height](#get-blocks-tip-height)
|
||||||
- [Get Blocks Tip Hash](#get-blocks-tip-hash)
|
- [Get Blocks Tip Hash](#get-blocks-tip-hash)
|
||||||
|
- Difficulty
|
||||||
|
- [Get Difficulty Adjustment](#get-difficulty-adjustment)
|
||||||
- Fees
|
- Fees
|
||||||
- [Get Fees Recommended](#get-fees-recommended)
|
- [Get Fees Recommended](#get-fees-recommended)
|
||||||
- [Get Fees Mempool Blocks](#get-fees-mempool-blocks)
|
- [Get Fees Mempool Blocks](#get-fees-mempool-blocks)
|
||||||
@ -376,6 +378,21 @@ const blocksTipHash = await blocks.getBlocksTipHash();
|
|||||||
console.log(blocksTipHash);
|
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**
|
### **Get Fees Recommended**
|
||||||
|
|
||||||
Returns our currently suggested fees for new transactions.
|
Returns our currently suggested fees for new transactions.
|
||||||
|
20
examples/html/bitcoin/difficulty.html
Normal file
20
examples/html/bitcoin/difficulty.html
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Page Title</title>
|
||||||
|
<script src="https://mempool.space/mempool.js"></script>
|
||||||
|
<script>
|
||||||
|
const init = async () => {
|
||||||
|
const {
|
||||||
|
bitcoin: { difficulty },
|
||||||
|
} = mempoolJS();
|
||||||
|
|
||||||
|
const difficultyAdjustment = await difficulty.getDifficultyAdjustment();
|
||||||
|
console.log(difficultyAdjustment);
|
||||||
|
|
||||||
|
};
|
||||||
|
init();
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body></body>
|
||||||
|
</html>
|
11
examples/nodejs/bitcoin/difficulty.ts
Normal file
11
examples/nodejs/bitcoin/difficulty.ts
Normal file
@ -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();
|
Loading…
x
Reference in New Issue
Block a user