<p>While reading the blockchain data directly is possible, you can only do so against stale data files -- as you can't reliably read the files while the client is running.</p>

<p>PyWallet and BitcoinTools are two such methods to do this.</p>

<p>Instead, the Bitcoin.org client (v0.7 and above) provides Raw Transactions support, in which you can decode a transaction to learn of its inputs, outputs and other attributes.  This, along with the rest of the API provides the ability to pull all the data from the blockchain that is needed, against a live instance:</p>

<ul>
<li><a href="http://en.bitcoin.it/wiki/Raw_Transactions" rel="nofollow">http://en.bitcoin.it/wiki/Raw_Transactions</a></li>
<li><a href="http://en.bitcoin.it/wiki/Raw_Transactions#decoderawtransaction_.3Chex_string.3E" rel="nofollow">http://en.bitcoin.it/wiki/Raw_Transactions#decoderawtransaction_.3Chex_string.3E</a></li>
</ul>

CC BY-SA 3.0
2012-10-07T16:31:35.957Z
2012-10-11T17:54:12.077Z
2012-10-11T17:54:12.077Z
Stephen Gornick
<p>Can anyone tell me where I can read about the structure of the files</p>

<pre><code> blk0001.dat 
 blk0002.dat
 blkindex.dat
</code></pre>

<p>I know that in these files bitcoin is saving all the information about transactions.
I would like to parse the files and save the information from these files in my local database.</p>

<p>[Note-these files are no longer used for Bitcoin-Qt/bitcoind version 0.8 and above.]</p>

CC BY-SA 3.0
2013-03-07T08:18:48.947Z
Note - these files are no longer used in Bitcoin-Qt/bitcoind version 0.8 and above.
Stephen Gornick
CC BY-SA 3.0
2012-10-07T16:26:57.040Z
Though those data files are BDB database files, the contents of blk000n.dat are simply raw concatenated bitcoin blocks: http://en.bitcoin.it/wiki/Data_directory
So you are essentially asking what is the structure of the raw bitcoin blocks.
Stephen Gornick
<transactions><blockchain><bitcoin-core>
What is the structure of blk001.dat and blkindex.dat?
Salvador Dali
# What is the structure of blk001.dat and blkindex.dat?

(Asked by: username_0 on 2012-10-07)

Can anyone tell me where I can read about the structure of the files
 blk0001.dat 
 blk0002.dat
 blkindex.dat

I know that in these files bitcoin is saving all the information about transactions.
I would like to parse the files and save the information from these files in my local database.
[Note-these files are no longer used for Bitcoin-Qt/bitcoind version 0.8 and above.]

**Tags:** transactions, blockchain, bitcoin-core

> **Comments:**
> **username_1**: Though those data files are BDB database files, the contents of blk000n.dat are simply raw concatenated bitcoin blocks: http://en.bitcoin.it/wiki/Data_directory So you are essentially asking what is the structure of the raw bitcoin blocks.  
> **username_1**: Note - these files are no longer used in Bitcoin-Qt/bitcoind version 0.8 and above.  

---

## 1 answers

### Answer by username_1 on 2012-10-07. Score: 3 | Accepted answer

While reading the blockchain data directly is possible, you can only do so against stale data files -- as you can't reliably read the files while the client is running.

PyWallet and BitcoinTools are two such methods to do this.

Instead, the Bitcoin.org client (v0.7 and above) provides Raw Transactions support, in which you can decode a transaction to learn of its inputs, outputs and other attributes. This, along with the rest of the API provides the ability to pull all the data from the blockchain that is needed, against a live instance:

* <http://en.bitcoin.it/wiki/Raw_Transactions>
* <http://en.bitcoin.it/wiki/Raw_Transactions#decoderawtransaction_.3Chex_string.3E>


---

