viem-goviem-go

estimateMaxPriorityFeePerGas

Returns an estimate for the max priority fee per gas for a transaction to be likely included in the next block

Import

Import the public actions package so you can call this action.

import "github.com/ChefBingbong/viem-go/actions/public"

Usage

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())

Returns

*big.Int

The max priority fee per gas in wei.

Parameters

Configuration options accepted by this action.

Block

  • Type: *types.Block
  • Optional

An 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,
})

JSON-RPC Method

Underlying JSON-RPC methods used by this action.