How to easily obtain the raw Block file?

12 replies 130 views
rogu3n0deMember
Posts: 6 · Reputation: 89
#1Jul 17, 2017, 10:22 PM
Hey everyone, I’m totally new to coding and I’m looking to grab the latest raw block in hex format as a text file. Any ideas on how to do this? I’ve tried using Blockchain explorers, but they don’t provide the raw files. I really need to get my hands on it.
4 Reply Quote Share
w0lf404Hero Member
Posts: 801 · Reputation: 2381
#2Jul 19, 2017, 05:11 AM
You can get raw data for each of the blocks from blockchair.com. For example, the following link gives you the raw data for block number 920744. Replace the block hash with the hash of any other block to get its raw data.
4 Reply Quote Share
maxi2017Senior Member
Posts: 262 · Reputation: 1550
#3Jul 19, 2017, 06:09 AM
Getting the raw hex block file without any coding experience is not something you can do by clicking around a standard web-based block explorer.  But, like hosemary mentioned, you could try a public blockchain API.  It still means making a request, but you don't have to write code – a web browser or a simple tool like curl can do the job.  Many popular explorers, such as Blockchair.com or BlockCypher, have free APIs just for this.  First, find the latest block hash or height.  The main explorer site can help, or you can get info via an API call. Like this: Then, find the "best_block_hash" value and paste that into the URL from the example before.  Or, find the "best_block_height" value and use that instead.  This will give you the raw data for the latest block on the bitcoin chain.
2 Reply Quote Share
w0lf404Hero Member
Posts: 801 · Reputation: 2381
#4Jul 19, 2017, 06:31 AM
^^^ Adding a tip: to get the latest block hash, use this url: Then combine it with the blockchair API endpoint above.
6 Reply Quote Share
gr3g.0rbitHero Member
Posts: 1025 · Reputation: 2646
#5Jul 19, 2017, 03:11 PM
Some blockexplorer API do, but its free version comes with a limit. Do you have a fully synced Bitcoin node? If so, just use getbestblockhash then use getblock "bestblockhash" 0 use verbose "0" like so. e.g. (Bitcoin Core Console): e.g. (bitcoin-cli):
1 Reply Quote Share
rogu3n0deMember
Posts: 6 · Reputation: 89
#6Jul 19, 2017, 07:24 PM
Thanks a lot for the helpful answers, I was able to see the raw Block on my Safari explorer, Brave refused to show it. And damn, its just a huge wall of text lol. I was expecting something more elegant, like the famous Genesis Block. But Im glad I got it. Also I do plan to become a node in the near future and film the entire process of downloading the Blockchain, but not right now. Im glad I can get the help I need here ^^
4 Reply Quote Share
w0lf404Hero Member
Posts: 801 · Reputation: 2381
#7Jul 19, 2017, 08:43 PM
The genesis block included only 1 transaction and that's why it was much smaller. It may be worth mentioning that you can also get the raw data for transactions separately, so that you deal with smaller data. This gives you the raw data for a single transaction. Just replace the transaction hash with the hash of any other transaction to get its raw data. To get the raw data of transactions, you can also go to mempool.space and click "Transaction hex" under the transaction details.
0 Reply Quote Share
gr3g.0rbitHero Member
Posts: 1025 · Reputation: 2646
#8Jul 19, 2017, 10:05 PM
Do they still have a working blockexplorer service? Because it doesn't work at my end, the URL itself, and either replacing "block" with the block hash/height or appending it to the given URL. It always says "403 - Forbidden" whether I use Tor or any clearnet browser.
5 Reply Quote Share
im_apeHero Member
Posts: 629 · Reputation: 3824
#9Jul 20, 2017, 02:45 AM
That doesn't look like a block explorer at all. Going to the home page, it is just hosting the bitcoin paper with 2 links on top one leading to a shady thing that slows down the browser and looks like it is selling some cloud mining service!
2 Reply Quote Share
gr3g.0rbitHero Member
Posts: 1025 · Reputation: 2646
#10Jul 20, 2017, 07:59 AM
AFAIK, it had a blockexplorer service before alongside with their wallet. That's why I'm wondering why Furball808 suggested it now that it's not what it used to be. Perhaps it's just a simple "haven't tested an old bookmark" before posting or something else.
0 Reply Quote Share
bear2019Full Member
Posts: 67 · Reputation: 484
#11Jul 21, 2017, 02:18 PM
The majority of the blockchain internet explorer services do not display the complete raw block files in hex format as it is standard practice. You can still obtain this information if you are in control of your own copy of the Bitcoin Core and utilize the getblock RPC method with verbosity setting to zero (0) to receive the complete raw hex block information. All that is necessary to do this is to download and install Bitcoin Core, allow time to sync, and execute the getblock RPC method with verbosity setting 0. If you want to receive the latest raw block data from the blockchain, you must be running a Bitcoin Core as this is the only way to receive accurate raw block data from the blockchain.
1 Reply Quote Share
im_apeHero Member
Posts: 629 · Reputation: 3824
#12Jul 21, 2017, 08:20 PM
That's a lot of work to just get a couple of blocks though. Here's a cool but slightly harder method: write a small script that connects to other peers on the bitcoin P2P network aka nodes, and request the block you need using a getdata message and the block's hash You can start by reading this to get the idea: https://www.righto.com/2014/02/bitcoins-hard-way-using-raw-bitcoin.html The process is pretty much the same. - Find peers, connect to one - Send/receive version and verack messages to complete the handshake process - Instead of last step of the above article (which is sending a tx message) you need to send a getdata message with an inv message that has MSG_WITNESS_BLOCK (2 | (1 << 30)) as its type.
1 Reply Quote Share
im_lynxHero Member
Posts: 515 · Reputation: 2161
#13Jul 24, 2017, 03:54 AM
I think it's easier to use mempool.space's GET Block Raw endpoint. This gives you the raw block data and if you want that as a continuous hex string, xxd is there for you. On the command-line you can execute e.g. the following pipeline which gives you the Genesis block in hex: To obtain the block hash from a numerical block-height, see the following description of a suitable existing endpoint: https://mempool.space/docs/api/rest#get-block-height
4 Reply Quote Share

Related topics