Skip to content

Latest commit

 

History

History
55 lines (42 loc) · 1.78 KB

README.MD

File metadata and controls

55 lines (42 loc) · 1.78 KB

EGPP - Ethereum Gas Price Provider

A Golang library used to fetch Ethereum Gas Prices from different gas price providers.

Build Status GoDev license

Basic example

package main

import (
    "fmt"
    "log"

    "github.com/OsoianMarcel/egpp"
    "github.com/OsoianMarcel/egpp/common"
    "github.com/OsoianMarcel/egpp/providers/etherchain"
    "github.com/OsoianMarcel/egpp/providers/ethergasstation"
    "github.com/OsoianMarcel/egpp/providers/etherscan"
)

func main() {
    // Gas price providers
    providers := []common.Provider{
        ethergasstation.NewProvider(),
        etherchain.NewProvider(),
        etherscan.NewProvider(""),
    }

    // Requests the gas price values from providers in order and returns the first successful result
    gasPriceStruct, err := egpp.GetGasPriceWithFallback(providers)
    if err != nil {
        log.Fatal(err)
    }

    fmt.Printf("%+v\n", gasPriceStruct)
    // {Provider:Ether Gas Station Standard:9800 SafeLow:9200 Fast:14300 Fastest:14300}
}

Contribute

Contributions to the package are always welcome!

License

All contents of this package are licensed under the MIT license.