Learn practical skills, build real-world projects, and advance your career

Ethereum Gas Price Trends: A beginner's quick-and-dirty analysis

Growing interest in cryptocurrency has led to flurry of activity over the last several months, including large value spikes and a surge of development and competition. One interesting byproduct of this is that, on the Ethereum network, prices of both tokens and computations have risen, sometimes making small transfers quite cost prohibitive. (If you're curious about how that all works, you can learn about the basics of Ethereum on its official website.)

I recently bought up some cryptocurrency to dabble around in, but quickly found out that you can't go trading it willy-nilly—each transaction incurs a cost, and the cost can vary greatly from day to day or even hour to hour. This got me wondering: Is there an optimal time to trade to get the most economical transactions and keep fees low?

These transaction fees are called "gas," the idea being that they are kind of analogous to fuel in a car: you buy fuel at some price, and that fuel gets used up to take you from one place to another. In a kind of similar fashion, "gas" can be bought at a competitive price, and whoever processes your trade multiplies that price by the amount of computational units it takes to run your transaction ("consuming" it, in a sense) to get your tokens from one place to another. Since this is highly dependent upon supply and demand, it would make sense that gas prices might vary over the coarse of the week, peaking on some days or dropping on others, generally.

Luckily, there's some data on these prices, so we can go and figure that out! We'll be using Python in this notebook and leaning on a small handful of libraries to get our data, process it, evaluate it, and manipulate it to see what kinds of trends we can find.

A quick note on running this notebook

If you didn't already know, this is an executable Jupyter notebook. It's hosted on Jovian.ml, a platform for sharing data science projects. You can run and experiment with the code in a couple of ways—Jovian has some instructions for the various options in their documentation.

Let's get cracking!

Downloading the Dataset

Back to Contents

The template that this project originated from instructs you to use Kaggle and Jovian's opendatasets library to get data, but they don't have what we're looking for. We could theoretically nab the data and upload it to Kaggle like Jovian suggests, but that seems a tad unscrupulous. Instead, we're going to get our data from directly etherscan.io.

That means we'll have to get our hands a little bit dirty with Python's urllib package to get our dataset downloaded. Let's get Jovian and urllib set up.

!pip install jovian --upgrade --quiet