Skip to content

Commit 31c972f

Browse files
authored
ethclient: add BlobBaseFee method (#31290)
1 parent d2bbde2 commit 31c972f

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

ethclient/ethclient.go

+9
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,15 @@ func (ec *Client) SuggestGasTipCap(ctx context.Context) (*big.Int, error) {
598598
return (*big.Int)(&hex), nil
599599
}
600600

601+
// BlobBaseFee retrieves the current blob base fee.
602+
func (ec *Client) BlobBaseFee(ctx context.Context) (*big.Int, error) {
603+
var hex hexutil.Big
604+
if err := ec.c.CallContext(ctx, &hex, "eth_blobBaseFee"); err != nil {
605+
return nil, err
606+
}
607+
return (*big.Int)(&hex), nil
608+
}
609+
601610
type feeHistoryResultMarshaling struct {
602611
OldestBlock *hexutil.Big `json:"oldestBlock"`
603612
Reward [][]*hexutil.Big `json:"reward,omitempty"`

ethclient/ethclient_test.go

+9
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,15 @@ func testStatusFunctions(t *testing.T, client *rpc.Client) {
404404
t.Fatalf("unexpected gas tip cap: %v", gasTipCap)
405405
}
406406

407+
// BlobBaseFee
408+
blobBaseFee, err := ec.BlobBaseFee(context.Background())
409+
if err != nil {
410+
t.Fatalf("unexpected error: %v", err)
411+
}
412+
if blobBaseFee.Cmp(big.NewInt(1)) != 0 {
413+
t.Fatalf("unexpected blob base fee: %v", blobBaseFee)
414+
}
415+
407416
// FeeHistory
408417
history, err := ec.FeeHistory(context.Background(), 1, big.NewInt(2), []float64{95, 99})
409418
if err != nil {

0 commit comments

Comments
 (0)