ethclient

package
v0.7.9 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2025 License: GPL-3.0, LGPL-3.0 Imports: 14 Imported by: 23

Documentation

Overview

Package ethclient provides a client for the Ethereum RPC API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToBlockNumArg

func ToBlockNumArg(number *big.Int) string

Types

type BlockHook added in v0.7.6

type BlockHook interface {
	// OnBlockDecoded is called when a block is decoded. It can be used to
	// modify the block before it is returned to the caller.
	OnBlockDecoded(raw json.RawMessage, block *types.Block) error
}

BlockHook is an interface that can be implemented to modify the block after it has been decoded. This is useful for plugins that want to modify the block before it is returned to the caller.

type Client

type Client interface {
	Client() *rpc.Client
	Close()
	ChainConfig(context.Context) (*params.ChainConfigWithUpgradesJSON, error)
	ChainID(context.Context) (*big.Int, error)
	BlockByHash(context.Context, common.Hash) (*types.Block, error)
	BlockByNumber(context.Context, *big.Int) (*types.Block, error)
	BlockNumber(context.Context) (uint64, error)
	BlockReceipts(context.Context, rpc.BlockNumberOrHash) ([]*types.Receipt, error)
	HeaderByHash(context.Context, common.Hash) (*types.Header, error)
	HeaderByNumber(context.Context, *big.Int) (*types.Header, error)
	TransactionByHash(context.Context, common.Hash) (tx *types.Transaction, isPending bool, err error)
	TransactionSender(context.Context, *types.Transaction, common.Hash, uint) (common.Address, error)
	TransactionCount(context.Context, common.Hash) (uint, error)
	TransactionInBlock(context.Context, common.Hash, uint) (*types.Transaction, error)
	TransactionReceipt(context.Context, common.Hash) (*types.Receipt, error)
	SyncProgress(ctx context.Context) error
	SubscribeNewAcceptedTransactions(context.Context, chan<- *common.Hash) (ethereum.Subscription, error)
	SubscribeNewPendingTransactions(context.Context, chan<- *common.Hash) (ethereum.Subscription, error)
	SubscribeNewHead(context.Context, chan<- *types.Header) (ethereum.Subscription, error)
	NetworkID(context.Context) (*big.Int, error)
	BalanceAt(context.Context, common.Address, *big.Int) (*big.Int, error)
	BalanceAtHash(ctx context.Context, account common.Address, blockHash common.Hash) (*big.Int, error)
	StorageAt(context.Context, common.Address, common.Hash, *big.Int) ([]byte, error)
	StorageAtHash(ctx context.Context, account common.Address, key common.Hash, blockHash common.Hash) ([]byte, error)
	CodeAt(context.Context, common.Address, *big.Int) ([]byte, error)
	CodeAtHash(ctx context.Context, account common.Address, blockHash common.Hash) ([]byte, error)
	NonceAt(context.Context, common.Address, *big.Int) (uint64, error)
	NonceAtHash(ctx context.Context, account common.Address, blockHash common.Hash) (uint64, error)
	FilterLogs(context.Context, ethereum.FilterQuery) ([]types.Log, error)
	SubscribeFilterLogs(context.Context, ethereum.FilterQuery, chan<- types.Log) (ethereum.Subscription, error)
	AcceptedCodeAt(context.Context, common.Address) ([]byte, error)
	AcceptedNonceAt(context.Context, common.Address) (uint64, error)
	AcceptedCallContract(context.Context, ethereum.CallMsg) ([]byte, error)
	CallContract(context.Context, ethereum.CallMsg, *big.Int) ([]byte, error)
	CallContractAtHash(ctx context.Context, msg ethereum.CallMsg, blockHash common.Hash) ([]byte, error)
	SuggestGasPrice(context.Context) (*big.Int, error)
	SuggestGasTipCap(context.Context) (*big.Int, error)
	FeeHistory(ctx context.Context, blockCount uint64, lastBlock *big.Int, rewardPercentiles []float64) (*ethereum.FeeHistory, error)
	EstimateGas(context.Context, ethereum.CallMsg) (uint64, error)
	EstimateBaseFee(context.Context) (*big.Int, error)
	SendTransaction(context.Context, *types.Transaction) error
}

Client defines interface for typed wrappers for the Ethereum RPC API.

func Dial

func Dial(rawurl string) (Client, error)

Dial connects a client to the given URL.

func DialContext

func DialContext(ctx context.Context, rawurl string) (Client, error)

DialContext connects a client to the given URL with context.

func NewClient

func NewClient(c *rpc.Client) Client

NewClient creates a client that uses the given RPC client.

func NewClientWithHook added in v0.7.6

func NewClientWithHook(c *rpc.Client, hook BlockHook) Client

NewClientWithHook creates a client that uses the given RPC client and block hook.

Directories

Path Synopsis
Package subnetevmclient provides an RPC client for subnet-evm-specific APIs.
Package subnetevmclient provides an RPC client for subnet-evm-specific APIs.

Jump to

Keyboard shortcuts

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