How to Get Raw Block Files Easily?

12 replies 360 views
bear2019Member
Posts: 6 · Reputation: 234
#1Apr 5, 2022, 08:40 PM
I’m totally new to this coding stuff. I want to grab the raw hex file of the latest block. How do I do that? I've tried some blockchain explorers but they don't show the raw data. Really need it!
5 Reply Quote Share
chrisomegaFull Member
Posts: 158 · Reputation: 631
#2Apr 5, 2022, 10:41 PM
Check out blockchair.com. You can get raw data for any block there. Just replace the block hash in the link to get what you need.
4 Reply Quote Share
wallet21Senior Member
Posts: 164 · Reputation: 1361
#3Apr 6, 2022, 12:00 AM
Honestly, without coding skills, it’s tricky to get the raw hex block file just from typical web explorers. But yeah, like hosemary said, public blockchain APIs are your best bet. You can use a browser or a tool like curl to make requests. Look for the latest block hash first, either from an explorer or via an API call.
5 Reply Quote Share
0xGuruNewbie
Posts: 190 · Reputation: 19
#4Apr 6, 2022, 01:34 AM
Good tip! To get the latest block hash, use this URL: [insert info here]. Then combine it with blockchair’s API link.
2 Reply Quote Share
0xChadNewbie
Posts: 513 · Reputation: 3
#5Apr 6, 2022, 06:13 AM
Some APIs have limits on free versions, but you can get raw data if you’re running a fully synced Bitcoin node. Just use getbestblockhash, then getblock "bestblockhash" with verbosity set to 0.
4 Reply Quote Share
bear2019Member
Posts: 6 · Reputation: 234
#6Apr 6, 2022, 11:34 AM
Thanks for all the info! I finally managed to see the raw block using Safari. Brave wouldn’t load it. And wow, it’s just a massive wall of text lol. Thought it’d be prettier like the Genesis Block. Planning to run a node soon and record the whole process of downloading the blockchain. Appreciate the help!
4 Reply Quote Share
chrisomegaFull Member
Posts: 158 · Reputation: 631
#7Apr 8, 2022, 05:32 AM
The Genesis Block was tiny with just one transaction, that’s why it looked neat. By the way, you can get raw transaction data too, so it’s less overwhelming. Just use the transaction hash to access it.
5 Reply Quote Share
0xChadNewbie
Posts: 513 · Reputation: 3
#8Apr 8, 2022, 05:44 AM
Wait, does that block explorer even work anymore? I’m getting a 403 Forbidden error when I try the URL, no matter how I replace the hash or height.
5 Reply Quote Share
mr_apeNewbie
Posts: 401 · Reputation: 35
#9Apr 8, 2022, 07:04 AM
That site looks sketchy. The homepage just has a link to the Bitcoin whitepaper and some weird mining service that slows everything down.
0 Reply Quote Share
0xChadNewbie
Posts: 513 · Reputation: 3
#10Apr 8, 2022, 10:31 AM
AFAIK, they used to have a block explorer. Not sure why Furball808 suggested it now since it’s probably not what it used to be. Maybe just a case of not checking old bookmarks?
4 Reply Quote Share
BasedAltMember
Posts: 1 · Reputation: 233
#11Apr 8, 2022, 03:50 PM
Most blockchain explorers don’t show the complete raw block files in hex format, which is pretty standard. The best way is to have your own Bitcoin Core and use the getblock RPC method with verbosity set to zero. Just download Bitcoin Core, let it sync, and you’re good to go.
2 Reply Quote Share
mr_apeNewbie
Posts: 401 · Reputation: 35
#12Apr 10, 2022, 01:57 PM
Seems like too much hassle for a couple blocks. Here’s a cooler but more complex option: write a small script to connect to other nodes in the Bitcoin P2P network and request the block using a getdata message with the block’s hash. Start by checking this guide for more info on how to do it.
1 Reply Quote Share
Posts: 185 · Reputation: 37
#13Apr 12, 2022, 06:33 PM
Honestly, mempool.space's GET Block Raw endpoint is super easy. You can get the raw block data, and if you want it as a hex string, just use xxd. Here’s a command you can run for the Genesis block in hex. For block hashes from a numeric block height, check the API docs.
6 Reply Quote Share

Related topics