Exploring the Ethereum Blockchain with QuickBlocks Part 1

Stephen Jude
Sep 1, 2018 · 5 min read

Motivation and Background:

I have been an avid crypto enthusiast since late 2015. I vividly remember when the news of the DAO hack broke out soon after jumping down the proverbial crypto rabbit hole. I watched with complete fascination as the battle between the hacker and the white hats raged over the course of a couple weeks. But what fascinated me even more was the fact that this entire drama played out in the open for everyone to see! At least if you knew where and how to find the data.

Fast forward three years and I have learned a lot about the crypto space and programming. See, my background is not in computer science or programming. My day job is not related to crypto in the slightest. During the day I’m lucky enough to fly multiple aircraft (mainly fighters) as a test pilot for the USAF. My main responsibility as a test pilot is to gather data in one of the most dynamic environments known to man. That data in turn is used to ensure that the equipment the government buys is safe and effective so that my friends and peers have the right equipment that ensures they always come home safe.

Much like my day job, success or failure in the crypto space depends heavily on having the best data! The true power lies with those that knew how to take the data on these public blockchains and turn it into actionable intelligence.

Thus my interest in QuickBlocks. QuickBlocks promised to make it much easier and faster to get data off of an Ethereum node. I was ecstatic to learn of an open source project (thanks to Evan Van Ness’s excellent Week in Ethereum newsletter) that would allow me to use my own Ethereum node to explore questions I had about the inner workings of the Ethereum blockchain. Specifically I wanted to run programs that would monitor ERC20 tokens of interest to see if there was anything hidden in the data. The potential use cases are endless and the QuickBlocks website does a decent job of laying those uses cases out. But first, I had to learn how to use the software. Here is my story of using QuickBlocks, learning C++, and a couple lessons I learned about Ethereum itself:

QuickBlocks and the Quest for Better Ethereum Data:

Over the course of three years watching the crypto space from a distance, I picked up the basics of running my own Bitcoin and Ethereum node, the differences between different wallet software, blockchain explorers, and the very basics of programming. For programming, I started with Python because that seemed to be the hip language budding data scientists were using. When I heard about QuickBlocks I decided to also try my hand in C++, hoping that the little background in I had in Python would help me learn C++ faster. After a beginners course on Udemy I was just dangerous enough to give it a shot.

Beginning with QuickBlocks was easy enough. I simply followed the steps on Github to install the QuickBlocks software on my computer. Success! So far so good. Now that the software was successfully installed came the next big question: How do I actually use it??? This was not a trivial matter since I had very little background with C++. The next section highlights the basics of running C++ programs that most developers probably take for granted. The following topic can be skipped if you are an experienced C++ programmer and are familiar with makefiles, and setting up an IDE environment but may serve as a guide for those out there like me.

Running a Quickblocks Program

The first steps were to figure out how write a simple program that would query the Ethereum node and return the contents of a single block and display those results in the terminal. Luckily such a program is described in the introduction of the QuickBlocks documentation. Little did I know that the program was already written hidden within a somewhat difficult to find “Examples” folder.

However, the documentation was clearly written for someone with experience in compiling and running such programs. In my naivety I assumed that I could simply compile the program by running g++ -Wall -std=c++11 simple.cpp in the terminal. I was quick to discover that my guess was incorrect.

First C++ lesson: you will need to link to the header files directory and pass the appropriate linker flags for the libraries. After asking around in the QuickBlocks Slack (Mr. Rush is very helpful), I learned that I was working too hard! All I had to do was the use the makefile provided in the example folder. I missed this because frankly, I didn’t know to even look for it. By using the makefile, all of the compiling would be done for me with all of the correct flags passed just by typing the command make.

Success!

Great! Now I know how to compile and run the program (to run it, find the executable file in the bin folder that is created when you run make). It does not take much knowledge about makefiles to change them if you want to run a custom program. This is great if you have a full understanding the program you are writing and its expected output. However, I wanted more insight into how the different QuickBlock classes worked. I wanted to watch as the variables of my program changed during runtime while also monitoring memory and CPU usage. I tend to get more insight if I can pause a program, watch the variables, and step into functions. Sometimes you can pick up on unexpected trends in the data! More on this later. An IDE would allow me to accomplish all of this.

Setting up an IDE was not as trivial as I had hoped. Each one is different. In order to get it to compile a program correctly you need to ensure that the right header files and libraries are linked when the IDE compiles the program. I used the makefile to figure out the path of the header files to include (/usr/local/qblocks/include) as well as the correct libraries to link (-lwallet -ltoken -lacct -lether -lutil -lcurl). Figuring out where to change those options took some time and I won’t go into the details since it depends heavily on which IDE you choose. But if you end up using XCode, then I found the following article very helpful in setting up my project.

In part 2 I go into the basics of running a QuickBlocks program and setting up an account scraper program.

Coinmonks

Coinmonks is a non-profit Crypto educational publication. Follow us on Twitter @coinmonks Our other project — https://coincodecap.com

Stephen Jude

Written by

Coinmonks

Coinmonks

Coinmonks is a non-profit Crypto educational publication. Follow us on Twitter @coinmonks Our other project — https://coincodecap.com

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade