I'm trying to download a relatively up-to-date dataset of all blocks in JSON format, but haven't found a good solution:

  • cleos can only fetch blocks one by one ($ cleos get block n) which is way too slow;

  • nodeos saves the log as a binary log, and the mongodb and sql plugins from B1 don't seem to be usable in the latest release;

  • EOSTracker has an API, but (understandably) it throttles frequency of connections/number of blocks per page, and sometimes I get invalid responses (not sure if the HTTP API is documented anywhere)

Any other ideas? Other structured format than JSON is also welcome as long as it can be processed relatively fast with non-EOSIO tools (eg. SQL dump is also fine)

up vote 3 down vote accepted

The best way I found to download the ledger in a structured format is to use eosio::mongo_db_plugin on latest EOSIO release, run $ nodeos --mongo-uri mongodb://127.0.0.1:27017 --replay-blockchain, and then query using mongo or something like pymongo.

$ mongo
...
connecting to: mongodb://127.0.0.1:27017
...
> use EOS
switched to db EOS
> show collections
accounts
actions
block_states
blocks
transaction_traces
transactions
> db.accounts.find({"name": "eosio"})

Firstly create a json file:touch ledger.json

Then you can try this request to where nodeos running: curl --request POST \ --url http://127.0.0.1:8888/v1/chain/get_table_rows > ledger.json click for detail

Or you can use cleos --url http://127.0.0.1:8888 get table <contract> <scope> <table> > ledger.json click for detail

  • Thanks for the reply. Can't try it right now, but wouldn't that just return a (current) table of a smart contract rather than the entire ledger history (i.e. all blocks with all their data) – confused00 Jul 16 at 9:48
  • I guess there is no ledger logic like you are thinking. I do not understand EOS infrastructure yet. But probably that table means chain. Hope my answers helps someone or someone gives a descriptive answer. – fufu Jul 16 at 11:53

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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