Skip to content

Commit

Permalink
ethclient: add BlobBaseFee method (#31290)
Browse files Browse the repository at this point in the history
  • Loading branch information
islishude authored Mar 1, 2025
1 parent d2bbde2 commit 31c972f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ethclient/ethclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,15 @@ func (ec *Client) SuggestGasTipCap(ctx context.Context) (*big.Int, error) {
return (*big.Int)(&hex), nil
}

// BlobBaseFee retrieves the current blob base fee.
func (ec *Client) BlobBaseFee(ctx context.Context) (*big.Int, error) {
var hex hexutil.Big
if err := ec.c.CallContext(ctx, &hex, "eth_blobBaseFee"); err != nil {
return nil, err
}
return (*big.Int)(&hex), nil
}

type feeHistoryResultMarshaling struct {
OldestBlock *hexutil.Big `json:"oldestBlock"`
Reward [][]*hexutil.Big `json:"reward,omitempty"`
Expand Down
9 changes: 9 additions & 0 deletions ethclient/ethclient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,15 @@ func testStatusFunctions(t *testing.T, client *rpc.Client) {
t.Fatalf("unexpected gas tip cap: %v", gasTipCap)
}

// BlobBaseFee
blobBaseFee, err := ec.BlobBaseFee(context.Background())
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
if blobBaseFee.Cmp(big.NewInt(1)) != 0 {
t.Fatalf("unexpected blob base fee: %v", blobBaseFee)
}

// FeeHistory
history, err := ec.FeeHistory(context.Background(), 1, big.NewInt(2), []float64{95, 99})
if err != nil {
Expand Down

0 comments on commit 31c972f

Please sign in to comment.