blockscan

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2022 License: MIT Imports: 6 Imported by: 0

README

Blockscan


Chains supported
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

New a Scanner

How to get an api key?

// You can use "" as your api key, but not recommanded.
// You may suffer from some unpredictabale errors when requesting data form blockscans.
ethScanner, _ := blockscan.New(chainId.EthereumChainName, "YOUR API KEY")
avaxScanner, _ := blockscan.New(chainId.AvalancheChainName, "YOUR API KEY")
polyScanner, _ := blockscan.New(chainId.PolygonChainName, "YOUR API KEY")
...

To see more on etherscan api.

Accounts

Return the chain token(eth for ethereum) balance of an address.

Return the chain token(eth for ethereum) balances of a list of addresses.

Return the erc20 transactions(up to 10000) of an address between sepecific blocks.

Return all the erc20 transactions(no amount limit) of an address from block 0 till now.

Return the internal transactions(up to 10000) of an address between sepecific blocks.

Return all the internal transactions(no amount limit) of an address from block 0 till now.

Return the normal transactions(up to 10000) of an address between sepecific blocks.

Return all the normal transactions(no amount limit) of an address from block 0 till now.


Contracts

Return the contract abi.

Return the contract's source code.

Return the contract's name.

Return whether the address is a contract.

If the contract is not verified, will still return false.


Blocks

Return the block number at specific timestamp.


Logs

Return the events(up to 1000) of a topic0 between sepecific blocks.

Return all the events(no amount limit) of a topic0 from block 0 till now.


Gas

Return the gas price in wei.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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 BlockscanSourceCode added in v0.3.0

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

type BlockscanSourceCodeReq

type BlockscanSourceCodeReq struct {
	Status  string                `json:"status"`
	Message string                `json:"message"`
	Result  []BlockscanSourceCode `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 any) (int64, error)

Return the balance of a single address.

func (*Scanner) GetBalances added in v0.2.0

func (s *Scanner) GetBalances(addresses []string) (map[string]int64, error)

map[address] = balance. Return balances of up to 20 addresses.

func (*Scanner) GetBlockNumberByTimestamp added in v0.2.0

func (s *Scanner) GetBlockNumberByTimestamp(timestamp string) (int64, error)

Return the block number.

func (*Scanner) GetContractAbi added in v0.2.0

func (s *Scanner) GetContractAbi(address any) (AbiStruct, error)

Return the contract's abi.

func (*Scanner) GetContractName added in v0.2.0

func (s *Scanner) GetContractName(address any) (string, error)

Return the contract's name.

func (*Scanner) GetErc20Transactions added in v0.2.0

func (s *Scanner) GetErc20Transactions(address any, startBlock int, endBlock any) ([]BlockscanErc20Txs, error)

Return up to 10000 erc20 txs of an address.

func (*Scanner) GetErc20TransactionsAll added in v0.2.0

func (s *Scanner) GetErc20TransactionsAll(address any) ([]BlockscanErc20Txs, error)

Return all the erc20 txs of an address.

func (*Scanner) GetEvents added in v0.2.0

func (s *Scanner) GetEvents(topic0 string, address any, startBlock int, endBlock any) ([]BlockscanEvents, error)

Return up to 1000 events of an address.

func (*Scanner) GetEventsAll added in v0.2.0

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

Return all the events of an address.

func (*Scanner) GetGasPrice added in v0.2.0

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

Return gas price.

func (*Scanner) GetInternalTransactions added in v0.2.0

func (s *Scanner) GetInternalTransactions(address any, startBlock int, endBlock any) ([]BlockscanInternalTxs, error)

Return up to 10000 internal txs of an address.

func (*Scanner) GetInternalTransactionsAll added in v0.2.0

func (s *Scanner) GetInternalTransactionsAll(address any) ([]BlockscanInternalTxs, error)

Return all the internal txs of an address.

func (*Scanner) GetNormalTransactions added in v0.2.0

func (s *Scanner) GetNormalTransactions(address any, startBlock int, endBlock any) ([]BlockscanNormalTxs, error)

Return up to 10000 txs of an address.

func (*Scanner) GetNormalTransactionsAll added in v0.2.0

func (s *Scanner) GetNormalTransactionsAll(address any) ([]BlockscanNormalTxs, error)

Return all the txs of an address.

func (*Scanner) GetSourceCode added in v0.2.0

func (s *Scanner) GetSourceCode(address any) (BlockscanSourceCode, error)

Return the source code of a contract.

func (*Scanner) IsVerifiedContract added in v0.2.0

func (s *Scanner) IsVerifiedContract(address any) (bool, error)

Return whether the address is a verified contract. 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