Documentation
¶
Overview ¶
Package gethclient provides an RPC client for geth-specific APIs.
Index ¶
- type AccountResult
- type BlockOverrides
- type CallFrame
- type CallLog
- type CallTracerConfig
- type Client
- func (ec *Client) CallContract(ctx context.Context, msg ethereum.CallMsg, blockNumber *big.Int, ...) ([]byte, error)
- func (ec *Client) CallContractWithBlockOverrides(ctx context.Context, msg ethereum.CallMsg, blockNumber *big.Int, ...) ([]byte, error)
- func (ec *Client) CreateAccessList(ctx context.Context, msg ethereum.CallMsg) (*types.AccessList, uint64, string, error)
- func (ec *Client) GCStats(ctx context.Context) (*debug.GCStats, error)
- func (ec *Client) GetNodeInfo(ctx context.Context) (*p2p.NodeInfo, error)
- func (ec *Client) GetProof(ctx context.Context, account common.Address, keys []string, ...) (*AccountResult, error)
- func (ec *Client) MemStats(ctx context.Context) (*runtime.MemStats, error)
- func (ec *Client) SetHead(ctx context.Context, number *big.Int) error
- func (ec *Client) SubscribeFullPendingTransactions(ctx context.Context, ch chan<- *types.Transaction) (*rpc.ClientSubscription, error)
- func (ec *Client) SubscribePendingTransactions(ctx context.Context, ch chan<- common.Hash) (*rpc.ClientSubscription, error)
- func (ec *Client) TraceBlock(ctx context.Context, hash common.Hash, config *tracers.TraceConfig) (any, error)
- func (ec *Client) TraceCallWithCallTracer(ctx context.Context, msg ethereum.CallMsg, blockNrOrHash rpc.BlockNumberOrHash, ...) (*CallFrame, error)
- func (ec *Client) TraceTransaction(ctx context.Context, hash common.Hash, config *tracers.TraceConfig) (any, error)
- func (ec *Client) TraceTransactionWithCallTracer(ctx context.Context, txHash common.Hash, config *CallTracerConfig) (*CallFrame, error)
- type OverrideAccount
- type StorageResult
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 ¶ added in v1.12.0
type BlockOverrides = ethereum.BlockOverrides
BlockOverrides is an alias for ethereum.BlockOverrides.
type CallFrame ¶ added in v1.17.0
type CallFrame struct {
Type string `json:"type"`
From common.Address `json:"from"`
Gas uint64 `json:"gas"`
GasUsed uint64 `json:"gasUsed"`
To *common.Address `json:"to,omitempty"`
Input []byte `json:"input"`
Output []byte `json:"output,omitempty"`
Error string `json:"error,omitempty"`
RevertReason string `json:"revertReason,omitempty"`
Calls []CallFrame `json:"calls,omitempty"`
Logs []CallLog `json:"logs,omitempty"`
Value *big.Int `json:"value,omitempty"`
}
CallFrame contains the result of a call tracer run.
func (CallFrame) MarshalJSON ¶ added in v1.17.0
MarshalJSON marshals as JSON.
func (*CallFrame) UnmarshalJSON ¶ added in v1.17.0
UnmarshalJSON unmarshals from JSON.
type CallLog ¶ added in v1.17.0
type CallLog struct {
Address common.Address `json:"address"`
Topics []common.Hash `json:"topics"`
Data []byte `json:"data"`
Index uint `json:"index"`
Position uint `json:"position"`
}
CallLog represents a log emitted during a traced call.
func (CallLog) MarshalJSON ¶ added in v1.17.0
MarshalJSON marshals as JSON.
func (*CallLog) UnmarshalJSON ¶ added in v1.17.0
UnmarshalJSON unmarshals from JSON.
type CallTracerConfig ¶ added in v1.17.0
type CallTracerConfig struct {
// OnlyTopCall, when true, limits tracing to the main (top-level) call only.
OnlyTopCall bool
// WithLog, when true, includes log emissions in the trace output.
WithLog bool
// Timeout is the maximum duration the tracer may run.
// Zero means the server default (5s).
Timeout time.Duration
}
CallTracerConfig configures the call tracer for TraceTransactionWithCallTracer and TraceCallWithCallTracer.
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 (*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 ¶ added in v1.12.0
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) GetNodeInfo ¶
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) SetHead ¶
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 ¶ added in v1.11.0
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.
func (*Client) TraceBlock ¶ added in v1.16.2
func (ec *Client) TraceBlock(ctx context.Context, hash common.Hash, config *tracers.TraceConfig) (any, error)
TraceBlock returns the structured logs created during the execution of EVM and returns them as a JSON object.
func (*Client) TraceCallWithCallTracer ¶ added in v1.17.0
func (ec *Client) TraceCallWithCallTracer(ctx context.Context, msg ethereum.CallMsg, blockNrOrHash rpc.BlockNumberOrHash, overrides map[common.Address]OverrideAccount, blockOverrides *BlockOverrides, config *CallTracerConfig) (*CallFrame, error)
TraceCallWithCallTracer executes a call with the call tracer and returns a typed CallFrame. blockNrOrHash selects the block context for the call. overrides specifies state overrides (nil for none), blockOverrides specifies block header overrides (nil for none), and config configures the tracer (nil for defaults).
func (*Client) TraceTransaction ¶ added in v1.16.0
func (ec *Client) TraceTransaction(ctx context.Context, hash common.Hash, config *tracers.TraceConfig) (any, error)
TraceTransaction returns the structured logs created during the execution of EVM and returns them as a JSON object.
func (*Client) TraceTransactionWithCallTracer ¶ added in v1.17.0
func (ec *Client) TraceTransactionWithCallTracer(ctx context.Context, txHash common.Hash, config *CallTracerConfig) (*CallFrame, error)
TraceTransactionWithCallTracer traces a transaction with the call tracer and returns a typed CallFrame. If config is nil, defaults are used.
type OverrideAccount ¶
type OverrideAccount = ethereum.OverrideAccount
OverrideAccount is an alias for ethereum.OverrideAccount.