gasestimator

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Estimate

func Estimate(ctx context.Context, call *core.Message, opts *Options, gasCap uint64) (uint64, []byte, error)

Estimate returns the lowest possible gas limit that allows the transaction to run successfully with the provided context options. It returns an error if the transaction would always revert, or if there are unexpected failures.

Types

type Options

type Options struct {
	Config *params.ChainConfig // Chain configuration for hard fork selection
	Chain  core.ChainContext   // Chain context to access past block hashes
	Header *types.Header       // Header defining the block context to execute in
	State  *state.StateDB      // Pre-state on top of which to estimate the gas

	ErrorRatio float64 // Allowed overestimation ratio for faster estimation termination
}

Options are the contextual parameters to execute the requested call.

Whilst it would be possible to pass a blockchain object that aggregates all these together, it would be excessively hard to test. Splitting the parts out allows testing without needing a proper live chain.

Jump to

Keyboard shortcuts

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