ethclient: add BlobBaseFee method (#31290)

This commit is contained in:
Shude Li 2025-03-01 21:11:51 +08:00 committed by GitHub
parent d2bbde2f2d
commit 31c972febf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 0 deletions

View File

@ -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"`

View File

@ -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 {