Skip to content

fix: normalize eth_estimateGas for Hardhat on hpp#351

Merged
yashvanthbl137-crypto merged 1 commit intomasterfrom
CGARD-454-fix-hpp-estimate-gas
Apr 14, 2026
Merged

fix: normalize eth_estimateGas for Hardhat on hpp#351
yashvanthbl137-crypto merged 1 commit intomasterfrom
CGARD-454-fix-hpp-estimate-gas

Conversation

@yashvanthbl137-crypto
Copy link
Copy Markdown
Contributor

@yashvanthbl137-crypto yashvanthbl137-crypto commented Apr 13, 2026

Summary

Fixes failed eth_estimateGas during Hardhat contract deploys on HPP mainnet (--network hpp) when the estimate request includes gas / EIP-1559 fields from Hardhat + ethers. The hook normalizes the RPC payload to match a minimal { from, data, … } estimate (same idea as a minimal curl).

Problem

On HPP mainnet, eth_estimateGas could fail with contract creation code storage out of gas when the transaction object included fields such as gasLimit, gasPrice, maxFeePerGas, maxPriorityFeePerGas, or type. The same bytecode could estimate successfully when those fields were omitted.

@nomicfoundation/hardhat-ethers uses provider.send("eth_estimateGas", [...]), so adjusting only request() is not sufficient.

Solution

  • config/hppHardhatEstimateGasFix.ts: extendEnvironment wraps send and request when hre.network.name === 'hpp' (HPP mainnet only). For eth_estimateGas, strip: gas, gasLimit, gasPrice, maxFeePerGas, maxPriorityFeePerGas, type before forwarding.
  • hardhat.config.ts: import the module right after dotenv.config() so it loads for all Hardhat entrypoints.

HPP Sepolia (thpp) is unchanged — the workaround is not applied there.

Actual transaction broadcast / deploy txs are unchanged; only the estimateGas RPC shape is adjusted.

Ticket: CGARD-454

@yashvanthbl137-crypto
Copy link
Copy Markdown
Contributor Author

yashvanthbl137-crypto commented Apr 13, 2026

v4 contracts deployment tested locally(mainnet)
Screenshot 2026-04-13 at 5 10 12 PM

batcher contract deployment tested locally(mainnet)
Screenshot 2026-04-13 at 5 10 20 PM

@yashvanthbl137-crypto yashvanthbl137-crypto marked this pull request as ready for review April 13, 2026 11:41
@yashvanthbl137-crypto
Copy link
Copy Markdown
Contributor Author

HPP mainnet RPC returns contract creation code storage out of gas when the request includes bytecode plus gas and EIP-1559 fee fields.

Screenshot 2026-04-13 at 5 14 03 PM

eth_estimateGas succeeds (HTTP 200, result) without gas / fee fields in the params.

Screenshot 2026-04-13 at 5 14 18 PM

@yashvanthbl137-crypto yashvanthbl137-crypto merged commit b0cd0ae into master Apr 14, 2026
3 checks passed
@yashvanthbl137-crypto yashvanthbl137-crypto deleted the CGARD-454-fix-hpp-estimate-gas branch April 14, 2026 12:43
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