Giter Site home page Giter Site logo

andrecronje / ethgasstation-backend Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ethgasstation/ethgasstation-backend

1.0 2.0 1.0 87 KB

Adaptive Gas Price Oracle for Ethereum Blockchain

License: GNU General Public License v3.0

Python 100.00%

ethgasstation-backend's Introduction

ethgasstation

an adaptive gas price oracle for the ethereum blockchain

This is the backend for ethgasstation, written in Python 3. This python script is designed to monitor a local Geth 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).

Installation and Prerequisites

ethgasstation requires Python 3, MySQL/MariaDB, and Geth. 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 = http://localhost:6379

Redis password authentication is also supported by adding it to the output location string, e.g. http://:password@localhost:6379/.

Usage

To run the script as is on bare metal or a VM, manually:

  1. Edit settings.conf and install to an allowed directory.
  2. Install requirements using pip3 install -r requirements.txt
  3. Run ./ethgasstation.py or python3 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.

  1. Change the settings in settings.docker.conf.
  2. Run docker build -t ethgasstation-backend . from this directory.
  3. 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, respectively within your infrastructure.

ethgasstation-backend's People

Contributors

10a7 avatar ethgasstation avatar jorisbontje avatar bamos01 avatar

Stargazers

Roman Sivakov avatar

Watchers

Andre Cronje avatar James Cloos avatar

Forkers

eu09

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.