estimateMaxPriorityFeePerGas
Returns an estimate for the max priority fee per gas for a transaction to be likely included in the next block
Loading...
Returns an estimate for the max priority fee per gas for a transaction to be likely included in the next block
Import the public actions package so you can call this action.
import "github.com/ChefBingbong/viem-go/actions/public"An example showing how to construct a public client and estimate the max priority fee per gas.
import ( "context" "log"
"github.com/ChefBingbong/viem-go/actions/public" "github.com/ChefBingbong/viem-go/client" "github.com/ChefBingbong/viem-go/client/transport" "github.com/ChefBingbong/viem-go/chain/definitions")
ctx := context.Background()
publicClient, err := client.CreatePublicClient(client.PublicClientConfig{ Chain: definitions.Mainnet, Transport: transport.HTTP("https://eth.llamarpc.com"),})if err != nil { log.Fatal(err)}defer func() { _ = publicClient.Close() }()
maxPriorityFeePerGas, err := public.EstimateMaxPriorityFeePerGas(ctx, publicClient, public.EstimateMaxPriorityFeePerGasParameters{})if err != nil { log.Fatal(err)}log.Printf("Max priority fee per gas: %s", maxPriorityFeePerGas.String())*big.Int
The max priority fee per gas in wei.
Configuration options accepted by this action.
*types.BlockAn optional pre-fetched block to use for fallback calculations. If nil, the latest block will be fetched when needed.
block, err := public.GetBlock(ctx, publicClient, public.GetBlockParameters{})if err != nil { log.Fatal(err)}
maxPriorityFeePerGas, err := public.EstimateMaxPriorityFeePerGas(ctx, publicClient, public.EstimateMaxPriorityFeePerGasParameters{ Block: block,})Underlying JSON-RPC methods used by this action.
eth_maxPriorityFeePerGas (preferred)eth_getBlockByNumber + eth_gasPrice (fallback)