2

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)

2 Answers 2

3

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"})
0

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

2
  • 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
    Commented Jul 16, 2018 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.
    – fuat
    Commented Jul 16, 2018 at 11:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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