0

I am looking for how to export or save data from ethereum blocks in a json file using quickblocks.

  • Hi there. Can you provide a few more details on what you're trying to do? Why do you want the data in JSON format? Does it specifically need to be in JSON? From the QuickBlocks documentation: "We abhor JSON data, which in our estimation, is literally the worst way to deliver data imaginable". – Richard Horrocks Oct 22 '17 at 9:38
  • QuickBlocks, even though it abhors JSON data, delivers its data in that format by default. It is easy to consume. Exporting the entire blockchain to JSON will take up an astronomical amount of disc space. – Thomas Jay Rush Oct 22 '17 at 22:24
1

The C++ code example on the referenced page in the above comments shows how to get a single block.

CBlock block;
getBlock(block, 3500000);
cout << block << "\n"

Simply surround that code with for (int i = 0 ; i &lt; getLatestBlock() ; i++) and the entire blockchain will get printed to the screen. Redirect into a file, and you have what you want--but I warn you: it will take up an astronomical amount of disc space.

| improve this answer | |
  • then I have to edit the simple.cpp file and modify main to int main(int argc, const char *argv[]) { // Initialize the system and tell it where to find the blockchain data. etherlib_init("infura"); for (int i = 0 ; i &lt; getLatestBlock() ; i++) // Request the 3,500,000th block from Infura. Store it in 'block' CBlock block; getBlock(block, 3500000); // Print the block to the screen cout << block << "\n"; } return 0; } – MABROUK Medkarim Oct 22 '17 at 23:02
  • Yep. Then exit the edit and type 'make'. You've contacted us through email, we can continue the conversation there. – Thomas Jay Rush Oct 23 '17 at 3:03

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.