3

I want to parse the whole blockchain(I know it might sound a bit too much). I have installed both solidity and geth.

My idea was to get the current block that is being mined, essentially the current state of the blockchain, and go back to the tree until i find the genesis block.

Is that possible? It seems a bit hard because how can I get the current block? Is it possible to use another language than solidity? I tried to download the whole blockchain according to this answer, but all I got was some weird database files(I think its ms access) and I cannot read them.

Is there a better way?

5
  • Can you explain exactly why you want to do that? Yes it's possible but depending on your use case, using smart contract is probably not the best way. Not me also that it will require that you have a fully synced full node. – Nicolas Massart Feb 17 at 17:05
  • @NicolasMassart I am basically trying to retireve some transactions and some account data from the blockchain, they are all fields of every block. I absolutely agree that I do not need solidity but at the same time I did not see viable data by downloading the blockchain – kostas Feb 17 at 17:23
  • @NicolasMassart by full node you mean one with 32 ETH staked? – pcko1 Feb 22 at 9:37
  • No. Full nodes means it stores all blocks and states. It is different from archive node however which also store historical state. Nodes doesn't need to store any ethereum. – Xavier59 Feb 22 at 14:48
  • @Xavier59 As I understand (and read on the first result at google), archive nodes store the whole blockchain as you mentioned but full nodes store only the 128 latest blocks and then just syncs whenever a new block is available. Does that mean that I can do reverse lookup? Like for example get a block and then retrieve its previous one until, lets say I reach the genesis block – kostas Mar 2 at 9:53
5

There are 3 commons way to query the ethereum blockchain for now :

  • The Ethereum dataset from Google BigQuery. You can retrieve various information such as basic information about transactions, smart contract function calls, token (erc20) transfers ... You can query this using SQL. For example, here is a query to get the top 10 biggest ethereum holder :
select *
from `bigquery-public-data.crypto_ethereum.balances`
order by eth_balance desc
limit 10
  • TheGraph is an indexer heavily used by Ethereum dApps to index smart contracts calls and state in the form of subgraph and make it easily queryable with graphql. Moreover, while TheGraph was limited to Ethereum for now, it has recently announced that it was exploring integration for other blockchains such as Polkadot and Solana.

  • Using an archive node. An archive node store the full state of every smart contracts as well as all the transactions at every block. You can query the balance of an account, retrieve the full list of transactions at any block or make a call at a specific block.
    A few examples ...

    • Query balance of an address at a specific block : web3.eth.getBalance(address , blockNumber, callback)
    • Make a call at a specific block : myContract.methods.methodName().call(transactionObject, blockNumber, callback)
2
  • interesting answer, by archive node you mean one like infura.io ? – pcko1 Feb 22 at 9:36
  • 2
    @pcko1 infura does have paid archive node (they don't offer them for free for now). You can also run your own archive node but it takes multiple months to sync since they are very big. – Xavier59 Feb 22 at 14:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.