25

After beeing able to check account balances, I am looking for a method to list all transactions for a given Ethereum account through json-rpc protocol. I haven't found any method suitable for that on https://github.com/ethereum/wiki/wiki/JSON-RPC .

Similar to https://etherscan.io/txs?a=0xbb9bc244d798123fde783fcc1c72d3bb8c189413 I am trying to build an explorer that shows all transactions from a given account.

At How can all transactions sent to an address be found? a similar question is asked but I am not looking for a solution through a third party, but by querying directly to my ethereum node through json-rpc protocol.

Am I missing something? Is that possible to do through the json-rpc interface?

  • 1
    My hunch is that they index externally the transactions along this from property. There are a ton of other indices to be built actually. Can you add a link to your code? Sounds like an interesting project. – Xavier Leprêtre B9lab Sep 6 '16 at 15:42
15

If you want to build a explore like etherscan.io, you need to crawl all data in ethereum network and save all txs in the db.

There is no direct rpc method to obtain all transactions related to the account.

  • Why crawl and save into db again? ethereum clients already maintain their db. We just need to have API to get that data out. So it would be better to choose ethereum client of choice and add desired API. – Ayushya Mar 6 at 19:18
4

The accepted answer to How can all transactions sent to an address be found? does not involve a third party.

The script in the answer uses the Web3 Javascript API which:

Under the hood it communicates to a local node through RPC calls. web3.js works with any Ethereum node, which exposes an RPC layer.

For example, where the script does:

var block = eth.getBlock(i, true);

you can use JSON-RPC eth_getBlockByNumber

Returns information about a block by block number.

Parameters

  1. QUANTITY|TAG - integer of a block number, or the string "earliest", "latest" or "pending", as in the default block parameter.
  2. Boolean - If true it returns the full transaction objects, if false only the hashes of the transactions.

The Javascript API makes it easier than issuing JSON-RPC requests, but you can port the script to another language and issue JSON-RPC requests. Additionally, take note of the comment on the accepted answer that you will need more than a script to get "internal transactions".

  • So do you mean that to find out matching transactions (from or to a given address) I would need a script that full scans the entire blockchain? Is not the geth node capable of filtering out the matching transactions I am looking for? Aren't they indexed somehow on blockchain or the very node? Thx! – Juan Ignacio Pérez Sacristán Sep 7 '16 at 8:11
  • 3
    @JuanIgnacioPérezSacristán Nope, Ethereum didn't think this far ahead ;) – Sandwich Oct 23 '17 at 15:08
  • @JuanIgnacioPérezSacristán, Ethereum uses NoSQL database (LevelDB). It does not store table relations like a Relational Database. Using a Relational Database would impact performance because the amount of data is big. So, either you scan the entire DB or create a relational DB from the blockchain and query it with SQL. – Nulik Nov 27 '17 at 19:35
  • 1
    The amount of time required to parse all blocks for a given address is quite large. – nu everest Mar 9 '18 at 20:41
  • 1
    Yeah, but I need to get all transactions. Not just the one. – Melbourne Developer Jun 22 '18 at 2:51

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.