Skip to content

feat: return blob gas fields from getFeeHistory - #5634

Closed
mortezashojaei wants to merge 1 commit into
wevm:mainfrom
mortezashojaei:feat/fee-history-blob-fields
Closed

mortezashojaei wants to merge 1 commit into
wevm:mainfrom
mortezashojaei:feat/fee-history-blob-fields

Conversation

@mortezashojaei

@mortezashojaei mortezashojaei commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Resolves discussion #4436.

Problem

eth_feeHistory returns baseFeePerBlobGas and blobGasUsedRatio on post-Dencun nodes, and both are in the execution-apis spec. formatFeeHistory copies only the pre-4844 fields, so getFeeHistory drops them and the FeeHistory / RpcFeeHistory types don't declare them.

Consumers who need blob fees fall back to an untyped client.request and cast the result:

Other tools that price blobs read these same fields from their own RPC clients, e.g. l2beat. Alloy's FeeHistory includes them too.

Solution

  • FeeHistory gains optional baseFeePerBlobGas?: quantity[] | undefined and blobGasUsedRatio?: number[] | undefined, with TSDoc taken from the spec. RpcFeeHistory (and so the eth_feeHistory EIP-1193 return type) picks them up through the generic.
  • formatFeeHistory maps baseFeePerBlobGas to bigint and passes blobGasUsedRatio through, following the existing reward?.map pattern.

The fields are optional because pre-4844 nodes and some L2s don't return them. No new functions or options.

const { baseFeePerBlobGas, blobGasUsedRatio } = await client.getFeeHistory({
  blockCount: 4,
  rewardPercentiles: [],
})

Tests

Folded into the existing cases:

  • src/utils/formatters/feeHistory.test.ts: added blob fields to the existing RPC fixture and snapshot.
  • src/actions/public/getFeeHistory.test.ts: the existing snapshots now include the blob fields that the mainnet fork actually returns. Before this change those three snapshots stayed the same because the fields were dropped.
  • src/actions/public/getFeeHistory.test-d.ts: asserts baseFeePerBlobGas: bigint[] | undefined and blobGasUsedRatio: number[] | undefined (fails against main's types).

Docs: added the blob fields to the // @log: response in getFeeHistory.md.

Commands run locally:

  • pnpm test --run src/actions/public/getFeeHistory.test.ts src/utils/formatters/feeHistory.test.ts src/actions/public/estimateFeesPerGas.test.ts src/actions/public/estimateMaxPriorityFeePerGas.test.ts: 4 files passed (37 passed, 1 skipped)
  • pnpm test --run src/clients/decorators/public.test.ts: getFeeHistory passed. getProof failed against the default public fork RPC with distance to target block exceeds maximum proof window, which is unrelated to this change.
  • tsc -p src/tsconfig.json --noEmit: passed
  • A focused tsc run of the changed test files, including getFeeHistory.test-d.ts: passed
  • biome check on the changed files: clean

Compatibility

Additive only: two optional fields on a return type. Existing code compiles and behaves the same, except that results now also contain the blob arrays (or undefined when the node omits them).

AI assistance: prepared with Claude Code; I reviewed the diff and the test output.

@vercel

vercel Bot commented Nov 21, 2026

Copy link
Copy Markdown

@mortezashojaei is attempting to deploy a commit to the Wevm Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot

changeset-bot Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f22599e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
viem Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

jxom commented Nov 21, 2026

Copy link
Copy Markdown
Member

Thanks @mortezashojaei, this is a great addition! I've kept your commit and continued it in #5635 with a couple of small fixes on top: the formatter now omits the blob fields when a node doesn't return them (instead of leaving undefined keys), the new arrays are readonly, and the docs show the new fields. Closing this in favor of #5635.

@jxom jxom closed this Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants