blockscan

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BlockscanCnf = map[string]BlockscanInfo{
	constants.ArbitrumChainName:      {URLHead: "https://api.arbiscan.io/api?", APIKey: "BCJX4984KDQ8A3U9WWH8P2EQKN76YV8T5T"},
	constants.AvalancheChainName:     {URLHead: "https://api.snowtrace.io/api?", APIKey: "K6SR1G96B2SQBRWPI4JP8WXM6BCG62EPQ7"},
	constants.BinanaceSmartChainName: {URLHead: "https://api.bscscan.com/api?", APIKey: "34WQ9W88CSRHX4ZK59WNKKZYDAP5CEXINP"},
	constants.EthereumChainName:      {URLHead: "https://api.etherscan.io/api?", APIKey: "RAFFHS8XP7K1FCBDFZS4TI2C9VHQBG77RP"},
	constants.FantomChainName:        {URLHead: "https://api.ftmscan.com/api?", APIKey: "Q61VSDQJ7R6WQF5NJJRWDFZJJQDMW4ZR15"},
	constants.GoerliChainName:        {URLHead: "https://api-goerli.etherscan.io/api?", APIKey: "RAFFHS8XP7K1FCBDFZS4TI2C9VHQBG77RP"},
	constants.HecoChainName:          {URLHead: "https://api.hecoinfo.com/api?", APIKey: "KC7PPFXMH6V187SGUDWD2XMGPCJXQWSPM5"},
	constants.OptimismChainName:      {URLHead: "https://api-optimistic.etherscan.io/api?", APIKey: "RAFFHS8XP7K1FCBDFZS4TI2C9VHQBG77RP"},
	constants.PolygonChainName:       {URLHead: "https://api.polygonscan.com/api?", APIKey: "Q31QP1KF13D6E298AJQ6X5ZHN373VDMF2S"},
}

Functions

func GetBalance

func GetBalance(network string, address string, userApiKey string) (balance int, err error)

Get balance of a single address. If "userApiKey" is "", use default api key.

func GetBalances

func GetBalances(network string, addresses []string, userApiKey string) (res blockscanGetBalancesReq, err error)

Get balances of up to 20 addresses in one call. If "userApiKey" is "", use default api key.

func GetBlockNumberByTimestamp

func GetBlockNumberByTimestamp[T types.Integer | string](network string, timestamp T, userApiKey string) (blockNumber int, err error)

Use timestamp to get block number. If "userApiKey" is "", use default api key.

func GetContractAbi

func GetContractAbi(network string, address string, userApiKey string) (abi abiStruct, err error)

Get the contract's abi(if it is a verified contract) If "userApiKey" is "", use default api key

func GetContractName

func GetContractName(network string, address string, userApiKey string) (name string, err error)

Get the contract's name by its source code. If "userApiKey" is "", use default api key.

func GetErc20Transactions

func GetErc20Transactions[T int | string](network string, address string, startBlock int, endBlock T, userApiKey string) (res blockscanGetErc20TxsReq, err error)

Get up to 10000 erc20 txs of an address. If "userApiKey" is "", use default api key.

func GetErc20TransactionsAll

func GetErc20TransactionsAll(network string, address string, userApiKey string) (txs []blockscanErc20Txs, err error)

Get all the erc20 txs of an address. If "userApiKey" is "", use default api key.

func GetEvents

func GetEvents[T int | string](network string, topic0 string, address string, startblock int, endblock T, userApiKey string) (res blockscanGetEventsReq, err error)

Get up to 1000 events of an address. If "userApiKey" is "", use default api key.

func GetGasPrice

func GetGasPrice(network string, userApiKey string) (gasPrice int64, err error)

If "userApiKey" is "", use default api key.

func GetGasPriceAll

func GetGasPriceAll(networks []string, userApiKey string) (err error)

Get and print all chains' gas price by Gwei. If "userApiKey" is "", use default api key.

func GetInternalTransactions

func GetInternalTransactions[T int | string](network string, address string, startBlock int, endBlock T, userApiKey string) (res blockscanGetInternalTxsReq, err error)

Get up to 10000 internal txs of an address. If "userApiKey" is "", use default api key.

func GetInternalTransactionsAll

func GetInternalTransactionsAll(network string, address string, userApiKey string) (txs []blockscanInternalTxs, err error)

Get all the internal txs of an address. If "userApiKey" is "", use default api key.

func GetNormalTransactions

func GetNormalTransactions[T int | string](network string, address string, startBlock int, endBlock T, userApiKey string) (res blockscanGetNormalTxsReq, err error)

Get up to 10000 txs of an address. If "userApiKey" is "", use default api key.

func GetNormalTransactionsAll

func GetNormalTransactionsAll(network string, address string, userApiKey string) (txs []blockscanNormalTxs, err error)

Get all the txs of an address. If "userApiKey" is "", use default api key.

func GetSourceCode

func GetSourceCode(network string, address string, userApiKey string) (res blockscanSourceCodeReq, err error)

Get the source code of a contract. If "userApiKey" is "", use default api key.

func GetUrlAndKey

func GetUrlAndKey(network string) (urlHead string, apiKey string, err error)

Read the config and get api key.

func IsVerifiedContract

func IsVerifiedContract(network string, address string, userApiKey string) (isContract bool, err error)

Some contracts may not be verified, will be considered not contract. If "userApiKey" is "", use default api key.

Types

type BlockscanEvents

type BlockscanEvents struct {
	Address          string   `json:"address"`
	Topics           []string `json:"topics"`
	Data             string   `json:"data"`
	BlockNumber      string   `json:"blockNumber"`
	TimeStamp        string   `json:"timeStamp"`
	GasPrice         string   `json:"gasPrice"`
	GasUsed          string   `json:"gasUsed"`
	LogIndex         string   `json:"logIndex"`
	TransactionHash  string   `json:"transactionHash"`
	TransactionIndex string   `json:"transactionIndex"`
}

func GetEventsAll

func GetEventsAll(network string, topic0 string, address string, userApiKey string) (events []BlockscanEvents, err error)

Get all the events of an address. If "userApiKey" is "", use default api key.

type BlockscanInfo

type BlockscanInfo struct {
	URLHead string `json:"urlHead"`
	APIKey  string `json:"apiKey"`
}

Jump to

Keyboard shortcuts

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