'Raw or Hex of a Whole Bitcoin Block
I want to get the raw or hex version of a bitcoin block by its block number or block hash, but there seems to be no block explorer that does this. I found an answer introducing this URL: https://www.blockchain.com/btc/block/8765?format=hex but it doesn't seem to work. particularly I want the raw or hex of block number 6425.
Solution 1:[1]
You can use the getblock command in bitcoin-core with the value 0 for verbosity.
You can try this in directly to a bitcoin-core console window, or use bitcoin-cli.
Example:
>getbestblockhash
27c9c0439b96b38a846f762e362607c9cd97605de8b293b3234eaf2869a4da9a
>getblock 27c9c0439b96b38a846f762e362607c9cd97605de8b293b3234eaf2869a4da9a 0
0000002076fe9fe0e4df326461fdddc3836cf220a8395c3c5c1b6fa372deb692ebf6f5732e7beb0de9ff1dd4853c203b120eb4caeeed1901aaf43de5a831c4dcdba50bc54070cf60ffff7f200000000001020000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff03580101ffffffff0200f2052a010000001600146241cc8a5f1120019e0e0d8dca674d1f4f58b0ac0000000000000000266a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf90120000000000000000000000000000000000000000000000000000000000000000000000000
For the block at height 6425, the raw block in hex is...
01000000a0d4ea3416518af0b238fef847274fc768cd39d0dc44a0ea5ec0c2dd000000007edfbf7974109f1fd628f17dfefd4915f217e0ec06e0c74e45049d36850abca4bc0eb049ffff001d27d0031e0101000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0804ffff001d024f02ffffffff0100f2052a010000004341048a5294505f44683bbc2be81e0f6a91ac1a197d6050accac393aad3b86b2398387e34fedf0de5d9f185eb3f2c17f3564b9170b9c262aa3ac91f371279beca0cafac00000000
Solution 2:[2]
Blockchair has this api available: https://blockchair.com/api/docs#link_M31
Example for block 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
and see the raw_block field
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | premek.v |
