blockscan

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2022 License: MIT Imports: 7 Imported by: 0

README

Blockscan

Now support

chain id network blockscan
1 ethereum etherscan
10 optimism optimism
56 binance bscscan
128 heco hecoscan
137 polygon polygonscan
250 fantom ftmscan
42161 arbitrum arbiscan
43114 avalanche snowtrace

Functions

coming soons

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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 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 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 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) (gasPriceMap map[string]int64, err error)

Get and print all chains' gas price by Gwei. 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 AbiStruct

type AbiStruct []struct {
	Inputs []struct {
		InternalType string `json:"internalType"`
		Name         string `json:"name"`
		Type         string `json:"type"`
	} `json:"inputs"`
	StateMutability string `json:"stateMutability"`
	Type            string `json:"type"`
	Anonymous       bool   `json:"anonymous"`
	Name            string `json:"name"`
	Outputs         []struct {
		InternalType string `json:"internalType"`
		Name         string `json:"name"`
		Type         string `json:"type"`
	} `json:"outputs"`
}

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

type BlockscanErc20Txs

type BlockscanErc20Txs struct {
	BlockNumber       string `json:"blockNumber"`
	TimeStamp         string `json:"timeStamp"`
	Hash              string `json:"hash"`
	Nonce             string `json:"nonce"`
	BlockHash         string `json:"blockHash"`
	From              string `json:"from"`
	ContractAddress   string `json:"contractAddress"`
	To                string `json:"to"`
	Value             string `json:"value"`
	TokenName         string `json:"tokenName"`
	TokenSymbol       string `json:"tokenSymbol"`
	TokenDecimal      string `json:"tokenDecimal"`
	TransactionIndex  string `json:"transactionIndex"`
	Gas               string `json:"gas"`
	GasPrice          string `json:"gasPrice"`
	GasUsed           string `json:"gasUsed"`
	CumulativeGasUsed string `json:"cumulativeGasUsed"`
	Input             string `json:"input"`
	Confirmations     string `json:"confirmations"`
}

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.

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 BlockscanGasPriceReq

type BlockscanGasPriceReq struct {
	Jsonrpc string `json:"jsonrpc"`
	ID      int    `json:"id"`
	Result  string `json:"result"`
}

type BlockscanGetBalanceReq

type BlockscanGetBalanceReq struct {
	Status  string `json:"status"`
	Message string `json:"message"`
	Result  string `json:"result"`
}

type BlockscanGetBalancesReq

type BlockscanGetBalancesReq struct {
	Status  string `json:"status"`
	Message string `json:"message"`
	Result  []struct {
		Account string `json:"account"`
		Balance string `json:"balance"`
	} `json:"result"`
}

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.

type BlockscanGetErc20TxsReq

type BlockscanGetErc20TxsReq struct {
	Status  string              `json:"status"`
	Message string              `json:"message"`
	Result  []BlockscanErc20Txs `json:"result"`
}

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.

type BlockscanGetEventsReq

type BlockscanGetEventsReq struct {
	Status  string            `json:"status"`
	Message string            `json:"message"`
	Result  []BlockscanEvents `json:"result"`
}

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.

type BlockscanGetInternalTxsReq

type BlockscanGetInternalTxsReq struct {
	Status  string                 `json:"status"`
	Message string                 `json:"message"`
	Result  []BlockscanInternalTxs `json:"result"`
}

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.

type BlockscanGetNormalTxsReq

type BlockscanGetNormalTxsReq struct {
	Status  string               `json:"status"`
	Message string               `json:"message"`
	Result  []BlockscanNormalTxs `json:"result"`
}

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.

type BlockscanInternalTxs

type BlockscanInternalTxs struct {
	BlockNumber     string `json:"blockNumber"`
	TimeStamp       string `json:"timeStamp"`
	Hash            string `json:"hash"`
	From            string `json:"from"`
	To              string `json:"to"`
	Value           string `json:"value"`
	ContractAddress string `json:"contractAddress"`
	Input           string `json:"input"`
	Type            string `json:"type"`
	Gas             string `json:"gas"`
	GasUsed         string `json:"gasUsed"`
	TraceID         string `json:"traceId"`
	IsError         string `json:"isError"`
	ErrCode         string `json:"errCode"`
}

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.

type BlockscanNormalTxs

type BlockscanNormalTxs struct {
	BlockNumber       string `json:"blockNumber"`
	TimeStamp         string `json:"timeStamp"`
	Hash              string `json:"hash"`
	Nonce             string `json:"nonce"`
	BlockHash         string `json:"blockHash"`
	TransactionIndex  string `json:"transactionIndex"`
	From              string `json:"from"`
	To                string `json:"to"`
	Value             string `json:"value"`
	Gas               string `json:"gas"`
	GasPrice          string `json:"gasPrice"`
	IsError           string `json:"isError"`
	TxreceiptStatus   string `json:"txreceipt_status"`
	Input             string `json:"input"`
	ContractAddress   string `json:"contractAddress"`
	CumulativeGasUsed string `json:"cumulativeGasUsed"`
	GasUsed           string `json:"gasUsed"`
	Confirmations     string `json:"confirmations"`
}

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.

type BlockscanResultStringReq

type BlockscanResultStringReq struct {
	Status  string `json:"status"`
	Message string `json:"message"`
	Result  string `json:"result"`
}

type BlockscanSourceCodeReq

type BlockscanSourceCodeReq struct {
	Status  string `json:"status"`
	Message string `json:"message"`
	Result  []struct {
		SourceCode           string `json:"SourceCode"`
		Abi                  string `json:"ABI"`
		ContractName         string `json:"ContractName"`
		CompilerVersion      string `json:"CompilerVersion"`
		OptimizationUsed     string `json:"OptimizationUsed"`
		Runs                 string `json:"Runs"`
		ConstructorArguments string `json:"ConstructorArguments"`
		EVMVersion           string `json:"EVMVersion"`
		Library              string `json:"Library"`
		LicenseType          string `json:"LicenseType"`
		Proxy                string `json:"Proxy"`
		Implementation       string `json:"Implementation"`
		SwarmSource          string `json:"SwarmSource"`
	} `json:"result"`
}

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.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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