Add blockHeader instructions and examples.
This commit is contained in:
parent
47fa100786
commit
4cd7665e8c
@ -26,6 +26,7 @@ Interface to access the Bitcoin `mainet`, `testnet`, `signet` APIs.
|
|||||||
- [Get Block Txids](#get-block-txids)
|
- [Get Block Txids](#get-block-txids)
|
||||||
- [Get Block Txid](#get-block-txid)
|
- [Get Block Txid](#get-block-txid)
|
||||||
- [Get Block Raw](#get-block-raw)
|
- [Get Block Raw](#get-block-raw)
|
||||||
|
- [Get Blocks Header](#get-blocks-header)
|
||||||
- [Get Blocks Height](#get-blocks-height)
|
- [Get Blocks Height](#get-blocks-height)
|
||||||
- [Get Blocks](#get-blocks)
|
- [Get Blocks](#get-blocks)
|
||||||
- [Get Blocks Tip Height](#get-blocks-tip-height)
|
- [Get Blocks Tip Height](#get-blocks-tip-height)
|
||||||
@ -284,6 +285,25 @@ const blockRaw = await blocks.getBlockRaw({ hash });
|
|||||||
console.log(blockRaw);
|
console.log(blockRaw);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### **Get Blocks Header**
|
||||||
|
|
||||||
|
Returns the hex-encoded block header.
|
||||||
|
|
||||||
|
**Parameters:**
|
||||||
|
|
||||||
|
- {string} hash
|
||||||
|
|
||||||
|
[ [NodeJS Example](examples/nodejs/bitcoin/blocks.ts) ] [ [HTML Example](examples/html/bitcoin/blocks.html) ] [ [Top](#features) ]
|
||||||
|
|
||||||
|
```js
|
||||||
|
const {
|
||||||
|
bitcoin: { blocks },
|
||||||
|
} = mempoolJS();
|
||||||
|
|
||||||
|
const blockHeader = await blocks.getBlockHeader({ hash: '0000000000000000000065bda8f8a88f2e1e00d9a6887a43d640e52a4c7660f2' });
|
||||||
|
console.log(blockHeader);
|
||||||
|
```
|
||||||
|
|
||||||
### **Get Blocks Height**
|
### **Get Blocks Height**
|
||||||
|
|
||||||
Returns the hash of the block currently at `:height`.
|
Returns the hash of the block currently at `:height`.
|
||||||
|
@ -30,6 +30,9 @@
|
|||||||
const blockRaw = await blocks.getBlockRaw({ hash });
|
const blockRaw = await blocks.getBlockRaw({ hash });
|
||||||
console.log(blockRaw);
|
console.log(blockRaw);
|
||||||
|
|
||||||
|
const blockHeader = await blocks.getBlockHeader({ hash });
|
||||||
|
console.log(blockHeader);
|
||||||
|
|
||||||
const blockHeight = await blocks.getBlockHeight({ height: 0 });
|
const blockHeight = await blocks.getBlockHeight({ height: 0 });
|
||||||
console.log(blockHeight);
|
console.log(blockHeight);
|
||||||
|
|
||||||
|
@ -26,6 +26,9 @@ const init = async () => {
|
|||||||
const blockRaw = await blocks.getBlockRaw({ hash });
|
const blockRaw = await blocks.getBlockRaw({ hash });
|
||||||
console.log(blockRaw);
|
console.log(blockRaw);
|
||||||
|
|
||||||
|
const blockHeader = await blocks.getBlockHeader({ hash });
|
||||||
|
console.log(blockHeader);
|
||||||
|
|
||||||
const blockHeight = await blocks.getBlockHeight({ height: 0 });
|
const blockHeight = await blocks.getBlockHeight({ height: 0 });
|
||||||
console.log(blockHeight);
|
console.log(blockHeight);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user