blockscan

package module
v0.2.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 GetUrlAndKey

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

Read the config and get 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"`
}

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"`
}

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"`
}

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"`
}

type BlockscanGetErc20TxsReq

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

type BlockscanGetEventsReq

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

type BlockscanGetInternalTxsReq

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

type BlockscanGetNormalTxsReq

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

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"`
}

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"`
}

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"`
}

type Scanner added in v0.2.0

type Scanner struct {
	UrlHead string
	ApiKey  string
}

func New added in v0.2.0

func New(network string, apiKey string) (*Scanner, error)

Create a new scanner.

func (*Scanner) GetBalance added in v0.2.0

func (s *Scanner) GetBalance(address string) (balance int, err error)

Get balance of a single address.

func (*Scanner) GetBalances added in v0.2.0

func (s *Scanner) GetBalances(addresses []string) (res BlockscanGetBalancesReq, err error)

Get balances of up to 20 addresses in one call.

func (*Scanner) GetBlockNumberByTimestamp added in v0.2.0

func (s *Scanner) GetBlockNumberByTimestamp(timestamp string) (blockNumber int, err error)

Use timestamp to get block number.

func (*Scanner) GetContractAbi added in v0.2.0

func (s *Scanner) GetContractAbi(address string) (abi AbiStruct, err error)

Get the contract's abi(if it is a verified contract)

func (*Scanner) GetContractName added in v0.2.0

func (s *Scanner) GetContractName(address string) (name string, err error)

Get the contract's name by its source code.

func (*Scanner) GetErc20Transactions added in v0.2.0

func (s *Scanner) GetErc20Transactions(address string, startBlock int, endBlock any) (res BlockscanGetErc20TxsReq, err error)

Get up to 10000 erc20 txs of an address.

func (*Scanner) GetErc20TransactionsAll added in v0.2.0

func (s *Scanner) GetErc20TransactionsAll(address string) (txs []BlockscanErc20Txs, err error)

Get all the erc20 txs of an address.

func (*Scanner) GetEvents added in v0.2.0

func (s *Scanner) GetEvents(topic0 string, address string, startBlock int, endBlock any) (res BlockscanGetEventsReq, err error)

Get up to 1000 events of an address.

func (*Scanner) GetEventsAll added in v0.2.0

func (s *Scanner) GetEventsAll(topic0 string, address string) (events []BlockscanEvents, err error)

Get all the events of an address.

func (*Scanner) GetGasPrice added in v0.2.0

func (s *Scanner) GetGasPrice() (gasPrice int64, err error)

Get gas price.

func (*Scanner) GetInternalTransactions added in v0.2.0

func (s *Scanner) GetInternalTransactions(address string, startBlock int, endBlock any) (res BlockscanGetInternalTxsReq, err error)

Get up to 10000 internal txs of an address.

func (*Scanner) GetInternalTransactionsAll added in v0.2.0

func (s *Scanner) GetInternalTransactionsAll(address string) (txs []BlockscanInternalTxs, err error)

Get all the internal txs of an address.

func (*Scanner) GetNormalTransactions added in v0.2.0

func (s *Scanner) GetNormalTransactions(address string, startBlock int, endBlock any) (res BlockscanGetNormalTxsReq, err error)

Get up to 10000 txs of an address.

func (*Scanner) GetNormalTransactionsAll added in v0.2.0

func (s *Scanner) GetNormalTransactionsAll(address string) (txs []BlockscanNormalTxs, err error)

Get all the txs of an address.

func (*Scanner) GetSourceCode added in v0.2.0

func (s *Scanner) GetSourceCode(address string) (res BlockscanSourceCodeReq, err error)

Get the source code of a contract.

func (*Scanner) IsVerifiedContract added in v0.2.0

func (s *Scanner) IsVerifiedContract(address string) (isContract bool, err error)

Some contracts may not be verified, will be considered not contract.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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