This is the backend for ethgasstation, written in Python 3. This python script is designed to monitor a local Geth or Parity node. It will record data about pending and mined transactions, including the transactions in your node's transaction pool. Its main purpose is to generate adaptive gas price estimates that enable you to know what gas price to use depending on your confirmation time needs. It generates these estimates based on miner policy estimates as well as the number of transactions in the txpool and the gas offered by the transaction.
The basic strategy is to use statistical modelling to predict confirmation times at all gas prices from 0-100 gwei at the current state of the txpool and minimum gas prices accepted in blocks over the last 200 blocks. Then, it selects the gas price that gives the desired confirmation time assuming standard gas offered (higher than 1m gas is slower).
ethgasstation requires Python 3, MySQL/MariaDB, and Geth/Parity. You will
need to modify settings.conf
for your specific environment; some (insecure)
defaults are set to get you up and running.
The oracle outputs JSON files. These files are stored in the output
directory specified by the settings.conf
file. You may output these JSON
strings to files by setting json.output_type
to file
and
json.output_location
to a filepath, such as:
[json]
output_type = file
output_location = ./json
or you may set json.output_type
to Redis and give a redis connection string:
[json]
output_type = redis
output_location = https://localhost:6379
Redis password authentication is also supported by adding it to the output
location string, e.g. https://:password@localhost:6379/
.
To run the script as is on bare metal or a VM, manually:
- Edit
settings.conf
and install to an allowed directory. - Install requirements using
pip3 install -r requirements.txt
- Run
./ethgasstation.py
orpython3 ethgasstation.py
.
If you are running a frontend to ETH Gas Station, use the --generate-report
flag to generate detailed JSON reports for front-end or API consumption.
It is also possible to run the oracle as a Docker container.
- Change the settings in settings.docker.conf.
- Run
docker build -t ethgasstation-backend .
from this directory. - Run
docker run ethgasstation-backend:latest
.
In the Docker service, the Python script will dump data to JSON on Redis. You will need to update your settings.conf to the internal hostnames available for MariaDB, Redis, and geth or parity, respectively within your infrastructure.