ethereum

package
v0.55.1 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2025 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MultiCall deprecated

func MultiCall(
	ctx context.Context,
	client rpc.RPC,
	calls []types.Call,
	blockNumber types.BlockNumber,
) ([][]byte, error)

MultiCall calls multiple contracts in a single call.

https://github.com/mds1/multicall/

Deprecated: Use the multicall.AggregateCallables instead.

Types

type CachedLogs

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

CachedLogs caches Ethereum logs in memory up to a certain range.

func NewCachedLogs

func NewCachedLogs(getter LogsGetter, cacheMaxRange, getterMaxRange uint64) *CachedLogs

NewCachedLogs creates a new CachedLogs instance.

The getter provides logs for the requested block range. The cacheMaxRange is the maximum number of blocks that can be cached. The getterMaxRange is the maximum number of blocks that can be requested from the getter in a single call. If zero, the getter is called once for the entire range.

func (*CachedLogs) GetLogs

func (cl *CachedLogs) GetLogs(ctx context.Context, from, to uint64) ([]types.Log, error)

GetLogs returns logs for the requested block range.

type ERC20

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

func NewERC20

func NewERC20(client rpc.RPC) (*ERC20, error)

func (*ERC20) GetDetails

func (e *ERC20) GetDetails(ctx context.Context, addresses []types.Address) ([]ERC20Details, error)

func (*ERC20) GetSymbolAndDecimals

func (e *ERC20) GetSymbolAndDecimals(ctx context.Context, addresses []types.Address) (map[string]ERC20Details, error)

type ERC20Details

type ERC20Details struct {
	Address  types.Address
	Symbol   string
	Decimals int
}

type LogsGetter

type LogsGetter interface {
	GetLogs(ctx context.Context, fromBlock, toBlock uint64) ([]types.Log, error)
}

LogsGetter is an interface that provides Ethereum logs for a given block range.

type LogsIterator

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

LogsIterator provides methods to iterate over Ethereum logs in batches.

func NewLogsIterator

func NewLogsIterator(client LogsIteratorRPC, batchSize uint64, query types.FilterLogsQuery) *LogsIterator

NewLogsIterator creates a new LogsIterator instance.

func (*LogsIterator) IterateRange

func (i *LogsIterator) IterateRange(ctx context.Context, blocks uint64, fn func(ctx context.Context, log types.Log) (bool, error)) error

IterateRange iterates over logs within the specified block range. It calls the provided function for each log and stops iteration if the function returns false.

Method is not thread safe.

func (*LogsIterator) IterateSince

func (i *LogsIterator) IterateSince(ctx context.Context, since time.Time, fn func(ctx context.Context, log types.Log) (bool, error)) error

IterateSince iterates over logs until the specified time. It calls the provided function for each log and stops iteration if the function returns false.

Note, since logs don't have timestamps, only the timestamp of the oldest block in the batch is checked against the since time. This means some logs might be returned even if they are older than the specified time.

Method is not thread safe.

type LogsIteratorRPC

type LogsIteratorRPC interface {
	GetLogs(ctx context.Context, query *types.FilterLogsQuery) ([]types.Log, error)
	BlockNumber(ctx context.Context) (*big.Int, error)
	BlockByNumber(ctx context.Context, number types.BlockNumber, full bool) (*types.Block, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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