ethclient

package
v0.34.4 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EthGetLogsMethod               = "eth_getLogs"
	EthSyncingMethod               = "eth_syncing"
	EthBlockNumberMethod           = "eth_blockNumber"
	EthSendTransactionMethod       = "eth_sendTransaction"
	EthSendRawTransactionMethod    = "eth_sendRawTransaction"
	EthGetTransactionCountMethod   = "eth_getTransactionCount"
	EthAccountsMethod              = "eth_accounts"
	EthGetBlockByNumberMethod      = "eth_getBlockByNumber"
	EthGetTransactionByHashMethod  = "eth_getTransactionByHash"
	EthGetTransactionReceiptMethod = "eth_getTransactionReceipt"
	EthGasPriceMethod              = "eth_gasPrice"
	NetVersionMethod               = "net_version"
	Web3ClientVersionMethod        = "web3_clientVersion"
)
View Source
const BasicGasLimit = 21000

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	// Hex representation of a Keccak 256 hash
	Sha3Uncles string `json:"sha3Uncles"`
	// Hex representation of a Keccak 256 hash
	TransactionsRoot string `json:"transactionsRoot"`
	// Hex representation of a Keccak 256 hash
	ParentHash string `json:"parentHash"`
	// The address of the beneficiary to whom the mining rewards were given or null when its the pending block
	Miner string `json:"miner"`
	// Integer of the difficulty for this block
	Difficulty string `json:"difficulty"`
	// The total used gas by all transactions in this block
	GasUsed string `json:"gasUsed"`
	// The unix timestamp for when the block was collated
	Timestamp string `json:"timestamp"`
	// Array of transaction objects, or 32 Bytes transaction hashes depending on the last given parameter
	Transactions []string `json:"transactions"`
	// The block number or null when its the pending block
	Number string `json:"number"`
	// The block hash or null when its the pending block
	Hash string `json:"hash"`
	// Array of uncle hashes
	Uncles []string `json:"uncles"`
	// Hex representation of a Keccak 256 hash
	ReceiptsRoot string `json:"receiptsRoot"`
	// The 'extra data' field of this block
	ExtraData string `json:"extraData"`
	// Hex representation of a Keccak 256 hash
	StateRoot string `json:"stateRoot"`
	// Integer of the total difficulty of the chain until this block
	TotalDifficulty string `json:"totalDifficulty"`
	// Integer the size of this block in bytes
	Size string `json:"size"`
	// The maximum gas allowed in this block
	GasLimit string `json:"gasLimit"`
	// Randomly selected number to satisfy the proof-of-work or null when its the pending block
	Nonce string `json:"nonce"`
	// The bloom filter for the logs of the block or null when its the pending block
	LogsBloom string `json:"logsBloom"`
}

type EthClient

type EthClient struct {
	rpc.Client
}

func NewEthClient

func NewEthClient(cli rpc.Client) *EthClient

func (*EthClient) Accounts

func (c *EthClient) Accounts() ([]string, error)

func (*EthClient) AwaitTransaction

func (c *EthClient) AwaitTransaction(ctx context.Context, txHash string) (*Receipt, error)

Wait for a transaction to be mined/confirmed

func (*EthClient) BlockNumber

func (c *EthClient) BlockNumber() (uint64, error)

func (*EthClient) GasPrice

func (c *EthClient) GasPrice() (string, error)

func (*EthClient) GetBlockByNumber

func (c *EthClient) GetBlockByNumber(height string) (*Block, error)

func (*EthClient) GetLogs

func (c *EthClient) GetLogs(filter *Filter) ([]*EthLog, error)

func (*EthClient) GetTransactionByHash

func (c *EthClient) GetTransactionByHash(txHash string) (*web3.Transaction, error)

func (*EthClient) GetTransactionCount

func (c *EthClient) GetTransactionCount(address crypto.Address) (string, error)

func (*EthClient) GetTransactionReceipt

func (c *EthClient) GetTransactionReceipt(txHash string) (*Receipt, error)

func (*EthClient) NetVersion

func (c *EthClient) NetVersion() (string, error)

AKA ChainID

func (*EthClient) SendRawTransaction

func (c *EthClient) SendRawTransaction(txHex string) (string, error)

func (*EthClient) SendTransaction

func (c *EthClient) SendTransaction(tx *EthSendTransactionParam) (string, error)

func (*EthClient) Syncing

func (c *EthClient) Syncing() (bool, error)

func (*EthClient) Web3ClientVersion

func (c *EthClient) Web3ClientVersion() (string, error)

type EthFilter

type EthFilter struct {
	// The hex representation of the block's height
	FromBlock string `json:"fromBlock,omitempty"`
	// The hex representation of the block's height
	ToBlock string `json:"toBlock,omitempty"`
	// Yes this is JSON address since allowed to be singular
	Addresses []string `json:"address,omitempty"`
	// Array of 32 Bytes DATA topics. Topics are order-dependent. Each topic can also be an array of DATA with 'or' options
	Topics []string `json:"topics,omitempty"`
}

Duplicated here to allow for arrays of addresses

type EthLog

type EthLog struct {
	Topics []string `json:"topics"`
	// Hex representation of a Keccak 256 hash
	TransactionHash string `json:"transactionHash"`
	// Sender of the transaction
	Address string `json:"address"`
	// The hex representation of the Keccak 256 of the RLP encoded block
	BlockHash string `json:"blockHash"`
	// The hex representation of the block's height
	BlockNumber string `json:"blockNumber"`
	// Hex representation of a variable length byte array
	Data string `json:"data"`
	// Hex representation of the integer
	LogIndex string `json:"logIndex"`
	// Hex representation of the integer
	TransactionIndex string `json:"transactionIndex"`
}

type EthSendTransactionParam

type EthSendTransactionParam struct {
	// Address of the sender
	From string `json:"from"`
	// address of the receiver. null when its a contract creation transaction
	To string `json:"to,omitempty"`
	// The data field sent with the transaction
	Gas string `json:"gas,omitempty"`
	// The gas price willing to be paid by the sender in Wei
	GasPrice string `json:"gasPrice,omitempty"`
	// The gas limit provided by the sender in Wei
	Value string `json:"value,omitempty"`
	// Hex representation of a Keccak 256 hash
	Data string `json:"data"`
	// A number only to be used once
	Nonce string `json:"nonce,omitempty"`
}

This is wrong in web3/types.go

type Filter

type Filter struct {
	*rpcevents.BlockRange
	Addresses []crypto.Address
	Topics    []binary.Word256
}

func (*Filter) EthFilter

func (f *Filter) EthFilter() *EthFilter

type Receipt

type Receipt struct {
	// The hex representation of the block's height
	BlockNumber string `json:"blockNumber"`
	// Hex representation of the integer
	CumulativeGasUsed string `json:"cumulativeGasUsed"`
	// Hex representation of the integer
	GasUsed string `json:"gasUsed"`
	// An array of all the logs triggered during the transaction
	Logs []EthLog `json:"logs"`
	// A 2048 bit bloom filter from the logs of the transaction. Each log sets 3 bits though taking the low-order 11 bits of each of the first three pairs of bytes in a Keccak 256 hash of the log's byte series
	TransactionIndex string `json:"transactionIndex"`
	// Whether or not the transaction threw an error.
	Status string `json:"status"`
	// The hex representation of the Keccak 256 of the RLP encoded block
	BlockHash string `json:"blockHash"`
	// The contract address created, if the transaction was a contract creation, otherwise null
	ContractAddress string `json:"contractAddress"`
	// The sender of the transaction
	From string `json:"from"`
	// A 2048 bit bloom filter from the logs of the transaction. Each log sets 3 bits though taking the low-order 11 bits of each of the first three pairs of bytes in a Keccak 256 hash of the log's byte series
	LogsBloom string `json:"logsBloom"`
	// Destination address of the transaction
	To string `json:"to"`
	// Hex representation of a Keccak 256 hash
	TransactionHash string `json:"transactionHash"`
}

type TransactClient

type TransactClient struct {
	// contains filtered or unexported fields
}

Provides a partial implementation of the GRPC-generated TransactClient suitable for testing Vent on Ethereum

func NewTransactClient

func NewTransactClient(client ethClient) *TransactClient

func (*TransactClient) CallTxSync

func (cli *TransactClient) CallTxSync(ctx context.Context, tx *payload.CallTx,
	opts ...grpc.CallOption) (*exec.TxExecution, error)

func (*TransactClient) GetChainID

func (cli *TransactClient) GetChainID() (string, error)

func (*TransactClient) GetGasPrice

func (cli *TransactClient) GetGasPrice() (uint64, error)

func (*TransactClient) GetTransactionCount

func (cli *TransactClient) GetTransactionCount(address crypto.Address) (uint64, error)

func (*TransactClient) SendRawTransaction

func (cli *TransactClient) SendRawTransaction(tx *payload.CallTx, signer acm.AddressableSigner) (string, error)

func (*TransactClient) SendTransaction

func (cli *TransactClient) SendTransaction(tx *payload.CallTx) (string, error)

func (*TransactClient) WithAccounts

func (cli *TransactClient) WithAccounts(signers ...acm.AddressableSigner) *TransactClient

Jump to

Keyboard shortcuts

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