client

package
v2.0.5 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPreByzantiumTx = errors.New("pre-byzantium transaction does not support receipt status check")

ErrPreByzantiumTx transaction before 4,370,000 does not support receipt status check

Functions

This section is empty.

Types

type AccountBalanceParams

type AccountBalanceParams struct {
	Tag     string `json:"tag"`
	Address string `json:"address"`
}

func (AccountBalanceParams) GetUrlValues

func (p AccountBalanceParams) GetUrlValues() url.Values

type BlockNumberParams

type BlockNumberParams struct {
	Timestamp int64  `json:"timestamp"`
	Closest   string `json:"closest"`
}

func (BlockNumberParams) GetUrlValues

func (p BlockNumberParams) GetUrlValues() url.Values

type BlockRewardParams

type BlockRewardParams struct {
	BlockNo int `json:"blockno"`
}

func (BlockRewardParams) GetUrlValues

func (p BlockRewardParams) GetUrlValues() url.Values

type Client

type Client struct {

	// Verbose when true, talks a lot
	Verbose bool

	// BeforeRequest runs before every client request, in the same goroutine.
	// May be used in rate limit.
	// Request will be aborted, if BeforeRequest returns non-nil err.
	BeforeRequest func(module, action string, values url.Values) error

	// AfterRequest runs after every client request, even when there is an error.
	AfterRequest func(module, action string, values url.Values, outcome interface{}, requestErr error) error
	// contains filtered or unexported fields
}

Client etherscan API client Clients are safe for concurrent use by multiple goroutines.

func NewClient

func NewClient(chain chain.Chain, APIKey string) *Client

NewClient initialize a new etherscan API client please use pre-defined network value

func NewCustomized

func NewCustomized(config Customization) *Client

NewCustomized initialize a customized API client, useful when calling against etherscan-family API like BscScan.

func (*Client) AccountBalance

func (c *Client) AccountBalance(address string) (types.BigInt, error)

Refactored methods

func (*Client) BlockNumber

func (c *Client) BlockNumber(timestamp int64, closest string) (int, error)

BlockNumber gets the closest block number by UNIX timestamp

valid closest option: before, after

func (*Client) BlockReward

func (c *Client) BlockReward(blockNum int) (response.BlockRewards, error)

BlockReward gets block and uncle rewards by block number

func (*Client) BlocksMinedByAddress

func (c *Client) BlocksMinedByAddress(address string, page int, offset int) ([]response.MinedBlock, error)

func (*Client) ContractABI

func (c *Client) ContractABI(address string) (string, error)

ContractABI gets contract abi for verified contract source codes

func (*Client) ContractSource

func (c *Client) ContractSource(address string) ([]response.ContractSource, error)

ContractSource gets contract source code for verified contract source codes

func (*Client) ERC1155Transfers

func (c *Client) ERC1155Transfers(contractAddress, address *string, startBlock *int, endBlock *int, page int, offset int, desc bool) ([]response.ERC1155Transfer, error)

func (*Client) ERC20Transfers

func (c *Client) ERC20Transfers(contractAddress, address *string, startBlock *int, endBlock *int, page int, offset int, desc bool) ([]response.ERC20Transfer, error)

func (*Client) ERC721Transfers

func (c *Client) ERC721Transfers(contractAddress, address *string, startBlock *int, endBlock *int, page int, offset int, desc bool) ([]response.ERC721Transfer, error)

func (*Client) EtherLatestPrice

func (c *Client) EtherLatestPrice() (price response.LatestPrice, err error)

EtherLatestPrice gets the latest ether price, in BTC and USD

func (*Client) EtherTotalSupply

func (c *Client) EtherTotalSupply() (totalSupply types.BigInt, err error)

EtherTotalSupply gets total supply of ether

func (*Client) ExecutionStatus

func (c *Client) ExecutionStatus(txHash string) (response.ExecutionStatus, error)

ExecutionStatus checks contract execution status

func (*Client) GasEstimate

func (c *Client) GasEstimate(gasPrice int) (time.Duration, error)

GasEstimate gets estimated confirmation time (in seconds) at the given gas price

func (*Client) GasOracle

func (c *Client) GasOracle() (response.GasPrices, error)

GasOracle gets suggested gas prices (in Gwei)

func (*Client) GetLogs

func (c *Client) GetLogs(fromBlock, toBlock int, address, topic string) ([]response.Log, error)

GetLogs gets logs that match "topic" emitted by the specified "address" between the "fromBlock" and "toBlock"

func (*Client) InternalTxByAddress

func (c *Client) InternalTxByAddress(address string, startBlock *int, endBlock *int, page int, offset int, desc bool) ([]response.InternalTx, error)

func (*Client) MultiAccountBalance

func (c *Client) MultiAccountBalance(addresses ...string) ([]response.AccountBalance, error)

func (*Client) NormalTxByAddress

func (c *Client) NormalTxByAddress(address string, startBlock *int, endBlock *int, page int, offset int, desc bool) ([]response.NormalTx, error)

func (*Client) ReceiptStatus

func (c *Client) ReceiptStatus(txHash string) (int, error)

ReceiptStatus checks transaction receipt status

func (*Client) TokenBalance

func (c *Client) TokenBalance(contractAddress, address string) (types.BigInt, error)

func (*Client) TokenTotalSupply

func (c *Client) TokenTotalSupply(contractAddress string) (types.BigInt, error)

TokenTotalSupply gets total supply of token on specified contract address

func (*Client) UnclesMinedByAddress

func (c *Client) UnclesMinedByAddress(address string, page int, offset int) ([]response.MinedBlock, error)

type ContractParams

type ContractParams struct {
	Address string `json:"address"`
}

func (ContractParams) GetUrlValues

func (p ContractParams) GetUrlValues() url.Values

type Customization

type Customization struct {
	// Timeout for API call
	Timeout time.Duration
	// API key applied from Etherscan
	Key string
	// Base URL like `https://api.etherscan.io/api?`
	BaseURL string
	// When true, talks a lot
	Verbose bool
	// ChainID to be used
	Chain chain.Chain
	// HTTP Client to be used. Specifying this value will ignore the Timeout value set
	// Set your own timeout.
	Client *http.Client

	// BeforeRequest runs before every client request, in the same goroutine.
	// May be used in rate limit.
	// Request will be aborted, if BeforeRequest returns non-nil err.
	BeforeRequest func(module, action string, values url.Values) error

	// AfterRequest runs after every client request, even when there is an error.
	AfterRequest func(module, action string, values url.Values, outcome interface{}, requestErr error) error
}

Customization is used in NewCustomized()

type GasEstimateParams

type GasEstimateParams struct {
	GasPrice int `json:"gasPrice"`
}

func (GasEstimateParams) GetUrlValues

func (p GasEstimateParams) GetUrlValues() url.Values

type LogParams

type LogParams struct {
	FromBlock int    `json:"fromBlock"`
	ToBlock   int    `json:"toBlock"`
	Topic0    string `json:"topic0"`
	Address   string `json:"address"`
}

func (LogParams) GetUrlValues

func (p LogParams) GetUrlValues() url.Values

type MinedBlockParams

type MinedBlockParams struct {
	Address   string `json:"address"`
	BlockType string `json:"blocktype"`
	Page      int    `json:"page"`
	Offset    int    `json:"offset"`
}

func (MinedBlockParams) GetUrlValues

func (p MinedBlockParams) GetUrlValues() url.Values

type MultiAccountBalanceParams

type MultiAccountBalanceParams struct {
	Tag       string   `json:"tag"`
	Addresses []string `json:"address"`
}

func (MultiAccountBalanceParams) GetUrlValues

func (p MultiAccountBalanceParams) GetUrlValues() url.Values

type TokenBalanceParams

type TokenBalanceParams struct {
	ContractAddress string `json:"contractaddress"`
	Address         string `json:"address"`
	Tag             string `json:"tag"`
}

func (TokenBalanceParams) GetUrlValues

func (p TokenBalanceParams) GetUrlValues() url.Values

type TokenTotalSupplyParams

type TokenTotalSupplyParams struct {
	ContractAddress string `json:"contractaddress"`
}

func (TokenTotalSupplyParams) GetUrlValues

func (p TokenTotalSupplyParams) GetUrlValues() url.Values

type TokenTransferParams

type TokenTransferParams struct {
	ContractAddress *string `json:"contractaddress,omitempty"`
	Address         *string `json:"address,omitempty"`
	StartBlock      *int    `json:"startblock,omitempty"`
	EndBlock        *int    `json:"endblock,omitempty"`
	Page            int     `json:"page"`
	Offset          int     `json:"offset"`
	Sort            string  `json:"sort"`
}

func (TokenTransferParams) GetUrlValues

func (p TokenTransferParams) GetUrlValues() url.Values

type TransactionParams

type TransactionParams struct {
	TxHash string `json:"txhash"`
}

func (TransactionParams) GetUrlValues

func (p TransactionParams) GetUrlValues() url.Values

type TxListParams

type TxListParams struct {
	Address    string `json:"address"`
	StartBlock *int   `json:"startblock,omitempty"`
	EndBlock   *int   `json:"endblock,omitempty"`
	Page       int    `json:"page"`
	Offset     int    `json:"offset"`
	Sort       string `json:"sort"`
}

func (TxListParams) GetUrlValues

func (p TxListParams) GetUrlValues() url.Values

Jump to

Keyboard shortcuts

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