Documentation ¶
Index ¶
- func BigToHex(bigInt big.Int) string
- func Eth1() *big.Int
- func IntToHex(i int) string
- func ParseBigInt(value string) (big.Int, error)
- func ParseInt(value string) (int, error)
- func WithDebug(enabled bool) func(rpc *EthRPC)
- func WithHttpClient(client httpClient) func(rpc *EthRPC)
- func WithLogger(l logger) func(rpc *EthRPC)
- type Block
- type EthError
- type EthRPC
- func (rpc *EthRPC) Call(method string, params ...interface{}) (json.RawMessage, error)
- func (rpc *EthRPC) Eth1() *big.Int
- func (rpc *EthRPC) EthAccounts() ([]string, error)
- func (rpc *EthRPC) EthBlockNumber() (int, error)
- func (rpc *EthRPC) EthCall(transaction T, tag string) (string, error)
- func (rpc *EthRPC) EthCoinbase() (string, error)
- func (rpc *EthRPC) EthEstimateGas(transaction T) (int, error)
- func (rpc *EthRPC) EthGasPrice() (big.Int, error)
- func (rpc *EthRPC) EthGetBalance(address, block string) (big.Int, error)
- func (rpc *EthRPC) EthGetBlockByHash(hash string, withTransactions bool) (*Block, error)
- func (rpc *EthRPC) EthGetBlockByNumber(number int, withTransactions bool) (*Block, error)
- func (rpc *EthRPC) EthGetBlockTransactionCountByHash(hash string) (int, error)
- func (rpc *EthRPC) EthGetBlockTransactionCountByNumber(number int) (int, error)
- func (rpc *EthRPC) EthGetCode(address, block string) (string, error)
- func (rpc *EthRPC) EthGetCompilers() ([]string, error)
- func (rpc *EthRPC) EthGetFilterChanges(filterID string) ([]Log, error)
- func (rpc *EthRPC) EthGetFilterLogs(filterID string) ([]Log, error)
- func (rpc *EthRPC) EthGetLogs(params FilterParams) ([]Log, error)
- func (rpc *EthRPC) EthGetStorageAt(data string, position int, tag string) (string, error)
- func (rpc *EthRPC) EthGetTransactionByBlockHashAndIndex(blockHash string, transactionIndex int) (*Transaction, error)
- func (rpc *EthRPC) EthGetTransactionByBlockNumberAndIndex(blockNumber, transactionIndex int) (*Transaction, error)
- func (rpc *EthRPC) EthGetTransactionByHash(hash string) (*Transaction, error)
- func (rpc *EthRPC) EthGetTransactionCount(address, block string) (int, error)
- func (rpc *EthRPC) EthGetTransactionReceipt(hash string) (*TransactionReceipt, error)
- func (rpc *EthRPC) EthGetUncleCountByBlockHash(hash string) (int, error)
- func (rpc *EthRPC) EthGetUncleCountByBlockNumber(number int) (int, error)
- func (rpc *EthRPC) EthHashrate() (int, error)
- func (rpc *EthRPC) EthMining() (bool, error)
- func (rpc *EthRPC) EthNewBlockFilter() (string, error)
- func (rpc *EthRPC) EthNewFilter(params FilterParams) (string, error)
- func (rpc *EthRPC) EthNewPendingTransactionFilter() (string, error)
- func (rpc *EthRPC) EthProtocolVersion() (string, error)
- func (rpc *EthRPC) EthSendRawTransaction(data string) (string, error)
- func (rpc *EthRPC) EthSendTransaction(transaction T) (string, error)
- func (rpc *EthRPC) EthSign(address, data string) (string, error)
- func (rpc *EthRPC) EthSyncing() (*Syncing, error)
- func (rpc *EthRPC) EthUninstallFilter(filterID string) (bool, error)
- func (rpc *EthRPC) NetListening() (bool, error)
- func (rpc *EthRPC) NetPeerCount() (int, error)
- func (rpc *EthRPC) NetVersion() (string, error)
- func (rpc *EthRPC) RawCall(method string, params ...interface{}) (json.RawMessage, error)
- func (rpc *EthRPC) URL() string
- func (rpc *EthRPC) Web3ClientVersion() (string, error)
- func (rpc *EthRPC) Web3Sha3(data []byte) (string, error)
- type EthereumAPI
- type FilterParams
- type Log
- type Syncing
- type T
- type Transaction
- type TransactionReceipt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseBigInt ¶
ParseBigInt parse hex string value to big.Int
func WithHttpClient ¶
func WithHttpClient(client httpClient) func(rpc *EthRPC)
WithHttpClient set custom http client
Types ¶
type Block ¶
type Block struct { Number int Hash string ParentHash string Nonce string Sha3Uncles string LogsBloom string TransactionsRoot string StateRoot string Miner string Difficulty big.Int TotalDifficulty big.Int ExtraData string Size int GasLimit int GasUsed int Timestamp int Uncles []string Transactions []Transaction }
Block - block object
type EthRPC ¶
type EthRPC struct { Debug bool // contains filtered or unexported fields }
EthRPC - Ethereum rpc client
func (*EthRPC) Call ¶
func (rpc *EthRPC) Call(method string, params ...interface{}) (json.RawMessage, error)
Call returns raw response of method call
func (*EthRPC) EthAccounts ¶
EthAccounts returns a list of addresses owned by client.
func (*EthRPC) EthBlockNumber ¶
EthBlockNumber returns the number of most recent block.
func (*EthRPC) EthCall ¶
EthCall executes a new message call immediately without creating a transaction on the block chain.
func (*EthRPC) EthCoinbase ¶
EthCoinbase returns the client coinbase address
func (*EthRPC) EthEstimateGas ¶
EthEstimateGas makes a call or transaction, which won't be added to the blockchain and returns the used gas, which can be used for estimating the used gas.
func (*EthRPC) EthGasPrice ¶
EthGasPrice returns the current price per gas in wei.
func (*EthRPC) EthGetBalance ¶
EthGetBalance returns the balance of the account of given address in wei.
func (*EthRPC) EthGetBlockByHash ¶
EthGetBlockByHash returns information about a block by hash.
func (*EthRPC) EthGetBlockByNumber ¶
EthGetBlockByNumber returns information about a block by block number.
func (*EthRPC) EthGetBlockTransactionCountByHash ¶
EthGetBlockTransactionCountByHash returns the number of transactions in a block from a block matching the given block hash.
func (*EthRPC) EthGetBlockTransactionCountByNumber ¶
EthGetBlockTransactionCountByNumber returns the number of transactions in a block from a block matching the given block
func (*EthRPC) EthGetCode ¶
EthGetCode returns code at a given address.
func (*EthRPC) EthGetCompilers ¶
EthGetCompilers returns a list of available compilers in the client.
func (*EthRPC) EthGetFilterChanges ¶
EthGetFilterChanges polling method for a filter, which returns an array of logs which occurred since last poll.
func (*EthRPC) EthGetFilterLogs ¶
EthGetFilterLogs returns an array of all logs matching filter with given id.
func (*EthRPC) EthGetLogs ¶
func (rpc *EthRPC) EthGetLogs(params FilterParams) ([]Log, error)
EthGetLogs returns an array of all logs matching a given filter object.
func (*EthRPC) EthGetStorageAt ¶
EthGetStorageAt returns the value from a storage position at a given address.
func (*EthRPC) EthGetTransactionByBlockHashAndIndex ¶
func (rpc *EthRPC) EthGetTransactionByBlockHashAndIndex(blockHash string, transactionIndex int) (*Transaction, error)
EthGetTransactionByBlockHashAndIndex returns information about a transaction by block hash and transaction index position.
func (*EthRPC) EthGetTransactionByBlockNumberAndIndex ¶
func (rpc *EthRPC) EthGetTransactionByBlockNumberAndIndex(blockNumber, transactionIndex int) (*Transaction, error)
EthGetTransactionByBlockNumberAndIndex returns information about a transaction by block number and transaction index position.
func (*EthRPC) EthGetTransactionByHash ¶
func (rpc *EthRPC) EthGetTransactionByHash(hash string) (*Transaction, error)
EthGetTransactionByHash returns the information about a transaction requested by transaction hash.
func (*EthRPC) EthGetTransactionCount ¶
EthGetTransactionCount returns the number of transactions sent from an address.
func (*EthRPC) EthGetTransactionReceipt ¶
func (rpc *EthRPC) EthGetTransactionReceipt(hash string) (*TransactionReceipt, error)
EthGetTransactionReceipt returns the receipt of a transaction by transaction hash. Note That the receipt is not available for pending transactions.
func (*EthRPC) EthGetUncleCountByBlockHash ¶
EthGetUncleCountByBlockHash returns the number of uncles in a block from a block matching the given block hash.
func (*EthRPC) EthGetUncleCountByBlockNumber ¶
EthGetUncleCountByBlockNumber returns the number of uncles in a block from a block matching the given block number.
func (*EthRPC) EthHashrate ¶
EthHashrate returns the number of hashes per second that the node is mining with.
func (*EthRPC) EthNewBlockFilter ¶
EthNewBlockFilter creates a filter in the node, to notify when a new block arrives. To check if the state has changed, call EthGetFilterChanges.
func (*EthRPC) EthNewFilter ¶
func (rpc *EthRPC) EthNewFilter(params FilterParams) (string, error)
EthNewFilter creates a new filter object.
func (*EthRPC) EthNewPendingTransactionFilter ¶
EthNewPendingTransactionFilter creates a filter in the node, to notify when new pending transactions arrive. To check if the state has changed, call EthGetFilterChanges.
func (*EthRPC) EthProtocolVersion ¶
EthProtocolVersion returns the current ethereum protocol version.
func (*EthRPC) EthSendRawTransaction ¶
EthSendRawTransaction creates new message call transaction or a contract creation for signed transactions.
func (*EthRPC) EthSendTransaction ¶
EthSendTransaction creates new message call transaction or a contract creation, if the data field contains code.
func (*EthRPC) EthSign ¶
EthSign signs data with a given address. Calculates an Ethereum specific signature with: sign(keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)))
func (*EthRPC) EthSyncing ¶
EthSyncing returns an object with data about the sync status or false.
func (*EthRPC) EthUninstallFilter ¶
EthUninstallFilter uninstalls a filter with given id.
func (*EthRPC) NetListening ¶
NetListening returns true if client is actively listening for network connections.
func (*EthRPC) NetPeerCount ¶
NetPeerCount returns number of peers currently connected to the client.
func (*EthRPC) NetVersion ¶
NetVersion returns the current network protocol version.
func (*EthRPC) RawCall ¶
func (rpc *EthRPC) RawCall(method string, params ...interface{}) (json.RawMessage, error)
RawCall returns raw response of method call (Deprecated)
func (*EthRPC) Web3ClientVersion ¶
Web3ClientVersion returns the current client version.
type EthereumAPI ¶
type EthereumAPI interface { Web3ClientVersion() (string, error) Web3Sha3(data []byte) (string, error) NetVersion() (string, error) NetListening() (bool, error) NetPeerCount() (int, error) EthProtocolVersion() (string, error) EthSyncing() (*Syncing, error) EthCoinbase() (string, error) EthMining() (bool, error) EthHashrate() (int, error) EthGasPrice() (big.Int, error) EthAccounts() ([]string, error) EthBlockNumber() (int, error) EthGetBalance(address, block string) (big.Int, error) EthGetStorageAt(data string, position int, tag string) (string, error) EthGetTransactionCount(address, block string) (int, error) EthGetBlockTransactionCountByHash(hash string) (int, error) EthGetBlockTransactionCountByNumber(number int) (int, error) EthGetUncleCountByBlockHash(hash string) (int, error) EthGetUncleCountByBlockNumber(number int) (int, error) EthGetCode(address, block string) (string, error) EthSign(address, data string) (string, error) EthSendTransaction(transaction T) (string, error) EthSendRawTransaction(data string) (string, error) EthCall(transaction T, tag string) (string, error) EthEstimateGas(transaction T) (int, error) EthGetBlockByHash(hash string, withTransactions bool) (*Block, error) EthGetBlockByNumber(number int, withTransactions bool) (*Block, error) EthGetTransactionByHash(hash string) (*Transaction, error) EthGetTransactionByBlockHashAndIndex(blockHash string, transactionIndex int) (*Transaction, error) EthGetTransactionByBlockNumberAndIndex(blockNumber, transactionIndex int) (*Transaction, error) EthGetTransactionReceipt(hash string) (*TransactionReceipt, error) EthGetCompilers() ([]string, error) EthNewFilter(params FilterParams) (string, error) EthNewBlockFilter() (string, error) EthNewPendingTransactionFilter() (string, error) EthUninstallFilter(filterID string) (bool, error) EthGetFilterChanges(filterID string) ([]Log, error) EthGetFilterLogs(filterID string) ([]Log, error) EthGetLogs(params FilterParams) ([]Log, error) }
type FilterParams ¶
type FilterParams struct { FromBlock string `json:"fromBlock,omitempty"` ToBlock string `json:"toBlock,omitempty"` Address []string `json:"address,omitempty"` Topics [][]string `json:"topics,omitempty"` }
FilterParams - Filter parameters object
type Log ¶
type Log struct { Removed bool LogIndex int TransactionIndex int TransactionHash string BlockNumber int BlockHash string Address string Data string Topics []string }
Log - log object
func (*Log) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
type Syncing ¶
Syncing - object with syncing data info
func (*Syncing) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
type T ¶
type T struct { From string To string Gas int GasPrice *big.Int Value *big.Int Data string Nonce int }
T - input transaction object
func (T) MarshalJSON ¶
MarshalJSON implements the json.Unmarshaler interface.
type Transaction ¶
type Transaction struct { Hash string Nonce int BlockHash string BlockNumber *int TransactionIndex *int From string To string Value big.Int Gas int GasPrice big.Int Input string }
Transaction - transaction object
func (*Transaction) UnmarshalJSON ¶
func (t *Transaction) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface.
type TransactionReceipt ¶
type TransactionReceipt struct { TransactionHash string TransactionIndex int BlockHash string BlockNumber int CumulativeGasUsed int GasUsed int ContractAddress string Logs []Log LogsBloom string Root string Status string }
TransactionReceipt - transaction receipt object
func (*TransactionReceipt) UnmarshalJSON ¶
func (t *TransactionReceipt) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface.