etherscan

package
v0.20.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 20, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package etherscan provides Go access to the Etherscan API. Documentation: https://docs.etherscan.io/api-endpoints

Index

Constants

View Source
const (
	NetworkMainnet = "api.etherscan.io"
	NetworkGoerli  = "api-goerli.etherscan.io"
	NetworkSepolia = "api-sepolia.etherscan.io"
)

These are the current networks the API works against.

Variables

This section is empty.

Functions

func WithClient

func WithClient(client *http.Client) func(eth *Etherscan)

WithClient adds a custom client for processing requests. It's recommend to not use the default client and provide your own.

func WithHeader

func WithHeader(key string, value string) func(eth *Etherscan)

WithHeader adds a key/value pair to the request header for all calls made to the host. This is for things like authentication or application specific needs. These headers are already included: "Cache-Control": "no-cache", "Content-Type": "application/json", "Accept": "application/json"

func WithNetwork

func WithNetwork(network string) func(eth *Etherscan)

WithNetwork changes the default network which is Mainnet.

Types

type Etherscan

type Etherscan struct {
	// contains filtered or unexported fields
}

Etherscan represents support for accessing the Etherscan API.

func New

func New(apiKey string, options ...func(eth *Etherscan)) *Etherscan

New constructs a new Etherscan for API access.

func (*Etherscan) GasTracker

func (eth *Etherscan) GasTracker(ctx context.Context) (Gas, error)

GasTracker returns the current gas in GWei that should be proposed on the configured network.

type Gas

type Gas struct {
	LastBlock       int64
	SafeGasPrice    *big.Int
	ProposeGasPrice *big.Int
	FastGasPrice    *big.Int
	SuggestBaseFee  *big.Int
}

Gas represents the result from the gastracker/gasoracle call. All values are in Wei.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL