rpc

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChainId

func ChainId() *jsonrpc.RpcCall[*big.Int]

func GetBlockByHash

func GetBlockByHash(hash common.Hash, txDetails bool) *jsonrpc.RpcCall[*ethtypes.HeaderWithBody]

func GetBlockByNumber

func GetBlockByNumber(number *big.Int, txDetails bool) *jsonrpc.RpcCall[ethtypes.HeaderWithBody]

func GetBlockNumber

func GetBlockNumber() *jsonrpc.RpcCall[uint64]

Types

type EthRpcBackend

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

implements bind.ContractBackend

func AdoptClient

func AdoptClient(client jsonrpc.IRpcClient) *EthRpcBackend

func (*EthRpcBackend) BalanceAt

func (ec *EthRpcBackend) BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error)

BalanceAt returns the wei balance of the given account. The block number can be nil, in which case the balance is taken from the latest known block.

func (*EthRpcBackend) CallContract

func (ec *EthRpcBackend) CallContract(ctx context.Context, msg ethereum.CallMsg, blockNumber *big.Int) ([]byte, error)

CallContract executes a message call transaction, which is directly executed in the VM of the node, but never mined into the blockchain.

blockNumber selects the block height at which the call runs. It can be nil, in which case the code is taken from the latest known block. Note that state from very old blocks might not be available.

func (*EthRpcBackend) CallContractAtHash

func (ec *EthRpcBackend) CallContractAtHash(ctx context.Context, msg ethereum.CallMsg, blockHash common.Hash) ([]byte, error)

CallContractAtHash is almost the same as CallContract except that it selects the block by block hash instead of block height.

func (*EthRpcBackend) CodeAt

func (ec *EthRpcBackend) CodeAt(ctx context.Context, account common.Address, blockNumber *big.Int) ([]byte, error)

CodeAt returns the contract code of the given account. The block number can be nil, in which case the code is taken from the latest known block.

func (*EthRpcBackend) EstimateGas

func (ec *EthRpcBackend) EstimateGas(ctx context.Context, msg ethereum.CallMsg) (uint64, error)

EstimateGas tries to estimate the gas needed to execute a specific transaction based on the current pending state of the backend blockchain. There is no guarantee that this is the true gas limit requirement as other transactions may be added or removed by miners, but it should provide a basis for setting a reasonable default.

func (*EthRpcBackend) FeeHistory

func (ec *EthRpcBackend) FeeHistory(ctx context.Context, blockCount uint64, lastBlock *big.Int, rewardPercentiles []float64) (*ethereum.FeeHistory, error)

FeeHistory retrieves the fee market history.

func (*EthRpcBackend) FilterLogs

func (ec *EthRpcBackend) FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]types.Log, error)

FilterLogs executes a filter query.

func (*EthRpcBackend) HeaderByHash

func (ec *EthRpcBackend) HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error)

HeaderByHash returns the block header with the given hash.

func (*EthRpcBackend) HeaderByNumber

func (ec *EthRpcBackend) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)

HeaderByNumber returns a block header from the current canonical chain. If number is nil, the latest known header is returned.

func (*EthRpcBackend) NetworkID

func (ec *EthRpcBackend) NetworkID(ctx context.Context) (*big.Int, error)

NetworkID returns the network ID for this client.

func (*EthRpcBackend) NonceAt

func (ec *EthRpcBackend) NonceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (uint64, error)

NonceAt returns the account nonce of the given account. The block number can be nil, in which case the nonce is taken from the latest known block.

func (*EthRpcBackend) PendingBalanceAt

func (ec *EthRpcBackend) PendingBalanceAt(ctx context.Context, account common.Address) (*big.Int, error)

PendingBalanceAt returns the wei balance of the given account in the pending state.

func (*EthRpcBackend) PendingCallContract

func (ec *EthRpcBackend) PendingCallContract(ctx context.Context, msg ethereum.CallMsg) ([]byte, error)

PendingCallContract executes a message call transaction using the EVM. The state seen by the contract call is the pending state.

func (*EthRpcBackend) PendingCodeAt

func (ec *EthRpcBackend) PendingCodeAt(ctx context.Context, account common.Address) ([]byte, error)

PendingCodeAt returns the contract code of the given account in the pending state.

func (*EthRpcBackend) PendingNonceAt

func (ec *EthRpcBackend) PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)

PendingNonceAt returns the account nonce of the given account in the pending state. This is the nonce that should be used for the next transaction.

func (*EthRpcBackend) PendingStorageAt

func (ec *EthRpcBackend) PendingStorageAt(ctx context.Context, account common.Address, key common.Hash) ([]byte, error)

PendingStorageAt returns the value of key in the contract storage of the given account in the pending state.

func (*EthRpcBackend) PendingTransactionCount

func (ec *EthRpcBackend) PendingTransactionCount(ctx context.Context) (uint, error)

PendingTransactionCount returns the total number of transactions in the pending state.

func (*EthRpcBackend) SendTransaction

func (ec *EthRpcBackend) SendTransaction(ctx context.Context, tx *types.Transaction) error

SendTransaction injects a signed transaction into the pending pool for execution.

If the transaction was a contract creation use the TransactionReceipt method to get the contract address after the transaction has been mined.

func (*EthRpcBackend) StorageAt

func (ec *EthRpcBackend) StorageAt(ctx context.Context, account common.Address, key common.Hash, blockNumber *big.Int) ([]byte, error)

StorageAt returns the value of key in the contract storage of the given account. The block number can be nil, in which case the value is taken from the latest known block.

func (*EthRpcBackend) SubscribeFilterLogs

func (ec *EthRpcBackend) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)

SubscribeFilterLogs subscribes to the results of a streaming filter query.

func (*EthRpcBackend) SuggestGasPrice

func (ec *EthRpcBackend) SuggestGasPrice(ctx context.Context) (*big.Int, error)

SuggestGasPrice retrieves the currently suggested gas price to allow a timely execution of a transaction.

func (*EthRpcBackend) SuggestGasTipCap

func (ec *EthRpcBackend) SuggestGasTipCap(ctx context.Context) (*big.Int, error)

SuggestGasTipCap retrieves the currently suggested gas tip cap after 1559 to allow a timely execution of a transaction.

Jump to

Keyboard shortcuts

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