gethclient

package
v0.0.0-...-e00be93 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2023 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package gethclient provides an RPC client for geth-specific APIs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountResult

type AccountResult struct {
	Address      common.Address  `json:"address"`
	AccountProof []string        `json:"accountProof"`
	Balance      *big.Int        `json:"balance"`
	CodeHash     common.Hash     `json:"codeHash"`
	Nonce        uint64          `json:"nonce"`
	StorageHash  common.Hash     `json:"storageHash"`
	StorageProof []StorageResult `json:"storageProof"`
}

AccountResult is the result of a GetProof operation.

type BlockOverrides

type BlockOverrides struct {
	// Number overrides the block number.
	Number *big.Int
	// Difficulty overrides the block difficulty.
	Difficulty *big.Int
	// Time overrides the block timestamp. Time is applied only when
	// it is non-zero.
	Time uint64
	// GasLimit overrides the block gas limit. GasLimit is applied only when
	// it is non-zero.
	GasLimit uint64
	// Coinbase overrides the block coinbase. Coinbase is applied only when
	// it is different from the zero address.
	Coinbase common.Address
	// Random overrides the block extra data which feeds into the RANDOM opcode.
	// Random is applied only when it is a non-zero hash.
	Random common.Hash
	// BaseFee overrides the block base fee.
	BaseFee *big.Int
}

BlockOverrides specifies the set of header fields to override.

func (BlockOverrides) MarshalJSON

func (o BlockOverrides) MarshalJSON() ([]byte, error)

type Client

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

Client is a wrapper around rpc.Client that implements geth-specific functionality.

If you want to use the standardized Ethereum RPC functionality, use ethclient.Client instead.

func New

func New(c *rpc.Client) *Client

New creates a client that uses the given RPC client.

func (*Client) CallContract

func (ec *Client) CallContract(ctx context.Context, msg ethereum.CallMsg, blockNumber *big.Int, overrides *map[common.Address]OverrideAccount) ([]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.

overrides specifies a map of contract states that should be overwritten before executing the message call. Please use ethclient.CallContract instead if you don't need the override functionality.

func (*Client) CallContractWithBlockOverrides

func (ec *Client) CallContractWithBlockOverrides(ctx context.Context, msg ethereum.CallMsg, blockNumber *big.Int, overrides *map[common.Address]OverrideAccount, blockOverrides BlockOverrides) ([]byte, error)

CallContractWithBlockOverrides 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.

overrides specifies a map of contract states that should be overwritten before executing the message call.

blockOverrides specifies block fields exposed to the EVM that can be overridden for the call.

Please use ethclient.CallContract instead if you don't need the override functionality.

func (*Client) CreateAccessList

func (ec *Client) CreateAccessList(ctx context.Context, msg ethereum.CallMsg) (*types.AccessList, uint64, string, error)

CreateAccessList tries to create an access list for a specific transaction based on the current pending state of the blockchain.

func (*Client) GCStats

func (ec *Client) GCStats(ctx context.Context) (*debug.GCStats, error)

GCStats retrieves the current garbage collection stats from a geth node.

func (*Client) GetNodeInfo

func (ec *Client) GetNodeInfo(ctx context.Context) (*p2p.NodeInfo, error)

GetNodeInfo retrieves the node info of a geth node.

func (*Client) GetProof

func (ec *Client) GetProof(ctx context.Context, account common.Address, keys []string, blockNumber *big.Int) (*AccountResult, error)

GetProof returns the account and storage values of the specified account including the Merkle-proof. The block number can be nil, in which case the value is taken from the latest known block.

func (*Client) MemStats

func (ec *Client) MemStats(ctx context.Context) (*runtime.MemStats, error)

MemStats retrieves the current memory stats from a geth node.

func (*Client) SetHead

func (ec *Client) SetHead(ctx context.Context, number *big.Int) error

SetHead sets the current head of the local chain by block number. Note, this is a destructive action and may severely damage your chain. Use with extreme caution.

func (*Client) SubscribeFullPendingTransactions

func (ec *Client) SubscribeFullPendingTransactions(ctx context.Context, ch chan<- *types.Transaction) (*rpc.ClientSubscription, error)

SubscribeFullPendingTransactions subscribes to new pending transactions.

func (*Client) SubscribePendingTransactions

func (ec *Client) SubscribePendingTransactions(ctx context.Context, ch chan<- common.Hash) (*rpc.ClientSubscription, error)

SubscribePendingTransactions subscribes to new pending transaction hashes.

type OverrideAccount

type OverrideAccount struct {
	// Nonce sets nonce of the account. Note: the nonce override will only
	// be applied when it is set to a non-zero value.
	Nonce uint64

	// Code sets the contract code. The override will be applied
	// when the code is non-nil, i.e. setting empty code is possible
	// using an empty slice.
	Code []byte

	// Balance sets the account balance.
	Balance *big.Int

	// State sets the complete storage. The override will be applied
	// when the given map is non-nil. Using an empty map wipes the
	// entire contract storage during the call.
	State map[common.Hash]common.Hash

	// StateDiff allows overriding individual storage slots.
	StateDiff map[common.Hash]common.Hash
}

OverrideAccount specifies the state of an account to be overridden.

func (OverrideAccount) MarshalJSON

func (a OverrideAccount) MarshalJSON() ([]byte, error)

type StorageResult

type StorageResult struct {
	Key   string   `json:"key"`
	Value *big.Int `json:"value"`
	Proof []string `json:"proof"`
}

StorageResult provides a proof for a key-value pair.

Jump to

Keyboard shortcuts

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