diff --git a/README-bitcoin.md b/README-bitcoin.md index f404713a6..9b8d30340 100644 --- a/README-bitcoin.md +++ b/README-bitcoin.md @@ -26,6 +26,7 @@ Interface to access the Bitcoin `mainet`, `testnet`, `signet` APIs. - [Get Block Txids](#get-block-txids) - [Get Block Txid](#get-block-txid) - [Get Block Raw](#get-block-raw) + - [Get Blocks Header](#get-blocks-header) - [Get Blocks Height](#get-blocks-height) - [Get Blocks](#get-blocks) - [Get Blocks Tip Height](#get-blocks-tip-height) @@ -284,6 +285,25 @@ const blockRaw = await blocks.getBlockRaw({ hash }); 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** Returns the hash of the block currently at `:height`. diff --git a/examples/html/bitcoin/blocks.html b/examples/html/bitcoin/blocks.html index 7404bb00f..c13bbdb88 100644 --- a/examples/html/bitcoin/blocks.html +++ b/examples/html/bitcoin/blocks.html @@ -30,6 +30,9 @@ const blockRaw = await blocks.getBlockRaw({ hash }); console.log(blockRaw); + const blockHeader = await blocks.getBlockHeader({ hash }); + console.log(blockHeader); + const blockHeight = await blocks.getBlockHeight({ height: 0 }); console.log(blockHeight); diff --git a/examples/nodejs/bitcoin/blocks.ts b/examples/nodejs/bitcoin/blocks.ts index 2b9df1de3..dd8a74e78 100644 --- a/examples/nodejs/bitcoin/blocks.ts +++ b/examples/nodejs/bitcoin/blocks.ts @@ -26,6 +26,9 @@ const init = async () => { const blockRaw = await blocks.getBlockRaw({ hash }); console.log(blockRaw); + const blockHeader = await blocks.getBlockHeader({ hash }); + console.log(blockHeader); + const blockHeight = await blocks.getBlockHeight({ height: 0 }); console.log(blockHeight);