ethclient

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2021 License: Apache-2.0 Imports: 13 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"
	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

func EthAccounts

func EthAccounts(client rpc.Client) ([]string, error)

func EthBlockNumber

func EthBlockNumber(client rpc.Client) (uint64, error)

func EthGasPrice

func EthGasPrice(client rpc.Client) (string, error)

func EthGetTransactionByHash

func EthGetTransactionByHash(client rpc.Client, txHash string) (*web3.Transaction, error)

func EthGetTransactionCount

func EthGetTransactionCount(client rpc.Client, address crypto.Address) (string, error)

func EthSendRawTransaction

func EthSendRawTransaction(client rpc.Client, txHex string) (string, error)

func EthSendTransaction

func EthSendTransaction(client rpc.Client, tx *EthSendTransactionParam) (string, error)

func EthSyncing

func EthSyncing(client rpc.Client) (bool, error)

func NetVersion

func NetVersion(client rpc.Client) (string, error)

AKA ChainID

func Web3ClientVersion

func Web3ClientVersion(client rpc.Client) (string, error)

Types

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

func EthGetLogs

func EthGetLogs(client rpc.Client, filter *Filter) ([]*EthLog, error)

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

func AwaitTransaction

func AwaitTransaction(ctx context.Context, client rpc.Client, txHash string) (*Receipt, error)

Wait for a transaction to be mined/confirmed

func EthGetTransactionReceipt

func EthGetTransactionReceipt(client rpc.Client, txHash string) (*Receipt, error)

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 rpc.Client) *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