<p>Your plan is correct (use <code>getrawtransaction &lt;hash&gt; 1</code> to get JSON instead of HEX :D) but the RPC becomes slow > 60% of the blockchain because there's between 500 and 2k transactions to go through.
Make sure <code>txindex=1</code> is in your config so it has the rawTX data.</p>

<p>As suggested by George parsing the raw files stored will make a very significant difference, to save you a lot of work;
this project (by bitpay) already does a that nicely:<br>
<a href="https://github.com/bitpay/insight-api" rel="nofollow">https://github.com/bitpay/insight-api</a> </p>

CC BY-SA 3.0
2014-06-24T07:37:55.623Z
bump for closing this ;)?
Ruben de Vries
CC BY-SA 4.0
2021-12-10T01:21:29.797Z
Any code examples on how bitcore/insight-api can be used for this purpose?
Dr. Strangelove
CC BY-SA 3.0
2014-05-01T09:01:57.433Z
2014-05-01T09:01:57.433Z
Ruben de Vries
<p>I'd like to iterate through the entire block chain using RPC.  The process I intend to do is:</p>

<ol>
<li>getblockhash 1</li>
<li>getblock (input of #1 here)</li>
<li>iterate through each transaction with GetRawtransaction (input of tx field here)</li>
<li>After getting all transactions, call getblockhash 2 (or goto nextblockhash in block) </li>
</ol>

<p>I just want to make sure I'm enumerating the chain correctly</p>

<blockchain><json-rpc>
How do I iterate through the entire Blockchain using RPC?
makerofthings7
# How do I iterate through the entire Blockchain using RPC?

(Asked by: username_0 on 2014-03-13)

I'd like to iterate through the entire block chain using RPC. The process I intend to do is:

1. getblockhash 1
2. getblock (input of #1 here)
3. iterate through each transaction with GetRawtransaction (input of tx field here)
4. After getting all transactions, call getblockhash 2 (or goto nextblockhash in block)

I just want to make sure I'm enumerating the chain correctly

**Tags:** blockchain, json-rpc


---

## 1 answers

### Answer by username_1 on 2014-05-01. Score: 2

Your plan is correct (use `getrawtransaction  1` to get JSON instead of HEX :D) but the RPC becomes slow > 60% of the blockchain because there's between 500 and 2k transactions to go through.
Make sure `txindex=1` is in your config so it has the rawTX data.

As suggested by George parsing the raw files stored will make a very significant difference, to save you a lot of work;
this project (by bitpay) already does a that nicely:  
<https://github.com/bitpay/insight-api>

> **Comments:**
> **username_1**: bump for closing this ;)?  
> **username_2**: Any code examples on how bitcore/insight-api can be used for this purpose?  

---

