Documentation
¶
Overview ¶
Request info from blockscan.
Index ¶
- type AbiInputOutPut
- type ContractAbi
- type Erc20Txs
- type Events
- type InternalTxs
- type NormalTxs
- type Scanner
- func (s *Scanner) GetBalance(address string) (decimal.Decimal, error)
- func (s *Scanner) GetBalances(addresses ...string) (map[string]decimal.Decimal, error)
- func (s *Scanner) GetBlockNumberByTimestamp(timestamp int64) (int64, error)
- func (s *Scanner) GetContractAbi(address string) (ContractAbi, error)
- func (s *Scanner) GetContractName(address string) (string, error)
- func (s *Scanner) GetErc20Transactions(address string, startBlock int64, endBlock any) ([]Erc20Txs, error)
- func (s *Scanner) GetErc20TransactionsAll(address string) ([]Erc20Txs, error)
- func (s *Scanner) GetEvents(topic0 string, address string, startBlock int64, endBlock any) ([]Events, error)
- func (s *Scanner) GetEventsAll(topic0 string, address string) ([]Events, error)
- func (s *Scanner) GetGasPrice() (int64, error)
- func (s *Scanner) GetInternalTransactions(address string, startBlock int64, endBlock any) ([]InternalTxs, error)
- func (s *Scanner) GetInternalTransactionsAll(address string) ([]InternalTxs, error)
- func (s *Scanner) GetNormalTransactions(address string, startBlock int64, endBlock any) ([]NormalTxs, error)
- func (s *Scanner) GetNormalTransactionsAll(address string) ([]NormalTxs, error)
- func (s *Scanner) GetSourceCode(address string) ([]SourceCode, error)
- func (s *Scanner) IsVerifiedContract(address string) (bool, error)
- type SourceCode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AbiInputOutPut ¶ added in v0.5.0
type ContractAbi ¶ added in v0.4.0
type ContractAbi []struct {
Name string `json:"name"`
StateMutability string `json:"stateMutability"`
Type string `json:"type"`
Anonymous bool `json:"anonymous"`
Inputs []AbiInputOutPut `json:"inputs"`
Outputs []AbiInputOutPut `json:"outputs"`
}
type Erc20Txs ¶ added in v0.4.1
type Erc20Txs struct {
BlockNumber string `json:"blockNumber"` // block number
TimeStamp string `json:"timeStamp"` // timestamp
Hash string `json:"hash"` // tx hash
Nonce string `json:"nonce"` // tx nonce
BlockHash string `json:"blockHash"` // block hash
From string `json:"from"` // who sent this token
ContractAddress string `json:"contractAddress"` // token contract
To string `json:"to"` // who received this token
Value string `json:"value"` // value in WEI
TokenName string `json:"tokenName"` // token name
TokenSymbol string `json:"tokenSymbol"` // token symbol
TokenDecimal string `json:"tokenDecimal"` // token decimals
TransactionIndex string `json:"transactionIndex"` // tx index
Gas string `json:"gas"` // gas
GasPrice string `json:"gasPrice"` // gas price
GasUsed string `json:"gasUsed"` // gas used
CumulativeGasUsed string `json:"cumulativeGasUsed"` //
Input string `json:"input"` //
Confirmations string `json:"confirmations"` //
}
type Events ¶ added in v0.4.1
type Events struct {
Address string `json:"address"` // address
Topics []string `json:"topics"` // topics of this event
Data string `json:"data"` // call data of the event
BlockNumber string `json:"blockNumber"` // block number
TimeStamp string `json:"timeStamp"` // timestamp of the event
GasPrice string `json:"gasPrice"` // gas price when the event emitted
GasUsed string `json:"gasUsed"` // gas used
LogIndex string `json:"logIndex"` // log index
TransactionHash string `json:"transactionHash"` // tx hash
TransactionIndex string `json:"transactionIndex"` // tx index
}
type InternalTxs ¶ added in v0.4.1
type InternalTxs struct {
BlockNumber string `json:"blockNumber"` // tx block number
TimeStamp string `json:"timeStamp"` // tx timestamp
Hash string `json:"hash"` // tx hash
From string `json:"from"` // who sent the chain token
To string `json:"to"` // who received the chain token
Value string `json:"value"` // value in WEI
ContractAddress string `json:"contractAddress"` // contract address
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 NormalTxs ¶ added in v0.4.1
type NormalTxs struct {
BlockNumber string `json:"blockNumber"` // tx block number
TimeStamp string `json:"timeStamp"` // tx timestamp
Hash string `json:"hash"` // tx hash
Nonce string `json:"nonce"` // tx nonce
BlockHash string `json:"blockHash"` // tx block hash
TransactionIndex string `json:"transactionIndex"` // tx index
From string `json:"from"` // who call the contract
To string `json:"to"` // who received the call
Value string `json:"value"` // value in WEI
Gas string `json:"gas"` //
GasPrice string `json:"gasPrice"` //
IsError string `json:"isError"` //
TxreceiptStatus string `json:"txreceipt_status"` //
Input string `json:"input"` // call data
ContractAddress string `json:"contractAddress"` //
CumulativeGasUsed string `json:"cumulativeGasUsed"` //
GasUsed string `json:"gasUsed"` //
Confirmations string `json:"confirmations"` //
}
type Scanner ¶ added in v0.2.0
type Scanner struct {
UrlHead string // Url based on network.
ApiKey string // User's api key, length should be 34.
// contains filtered or unexported fields
}
func New ¶ added in v0.2.0
Create a new scanner.
To get an apikey on ethereum, visit https://docs.etherscan.io/getting-started/viewing-api-usage-statistics
func (*Scanner) GetBalance ¶ added in v0.2.0
Return the balance of a single address.
func (*Scanner) GetBalances ¶ added in v0.2.0
Return balances of up to 20 addresses. map[address] = balance.
func (*Scanner) GetBlockNumberByTimestamp ¶ added in v0.2.0
Return the block number.
func (*Scanner) GetContractAbi ¶ added in v0.2.0
func (s *Scanner) GetContractAbi(address string) (ContractAbi, error)
Return the contract's abi.
func (*Scanner) GetContractName ¶ added in v0.2.0
Return the contract's name.
func (*Scanner) GetErc20Transactions ¶ added in v0.2.0
func (s *Scanner) GetErc20Transactions(address string, startBlock int64, endBlock any) ([]Erc20Txs, error)
Return up to 10000 erc20 txs of an address.
func (*Scanner) GetErc20TransactionsAll ¶ added in v0.2.0
Return all the erc20 txs of an address.
func (*Scanner) GetEvents ¶ added in v0.2.0
func (s *Scanner) GetEvents(topic0 string, address string, startBlock int64, endBlock any) ([]Events, error)
Return up to 1000 events of an address.
Param:
topic0: The topic0 of the event. In most cases means the hash of the function name. address: The address. Can be string or common.Address startBlock: The block to start from. endBlock: The block to end. If greater than latest block number, or use "latest", will use the latest block number.
func (*Scanner) GetEventsAll ¶ added in v0.2.0
Return all the events of an address.
Param:
topic0: The topic0 of the event. In most cases means the hash of the function name. address: The address. Can be string or common.Address
func (*Scanner) GetGasPrice ¶ added in v0.2.0
Return gas price in WEI.
func (*Scanner) GetInternalTransactions ¶ added in v0.2.0
func (s *Scanner) GetInternalTransactions(address string, startBlock int64, endBlock any) ([]InternalTxs, error)
Return up to 10000 internal txs of an address.
func (*Scanner) GetInternalTransactionsAll ¶ added in v0.2.0
func (s *Scanner) GetInternalTransactionsAll(address string) ([]InternalTxs, error)
Return all the internal txs of an address.
func (*Scanner) GetNormalTransactions ¶ added in v0.2.0
func (s *Scanner) GetNormalTransactions(address string, startBlock int64, endBlock any) ([]NormalTxs, error)
Return up to 10000 txs of an address.
func (*Scanner) GetNormalTransactionsAll ¶ added in v0.2.0
Return all the txs of an address.
func (*Scanner) GetSourceCode ¶ added in v0.2.0
func (s *Scanner) GetSourceCode(address string) ([]SourceCode, error)
Return the source code of a contract.
type SourceCode ¶ added in v0.4.1
type SourceCode 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"`
}