-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Description
Check existing issues
- I checked there isn't already an issue for the bug I encountered.
Viem Version
2.22.10
Current Behavior
When sending transaction using writeContract - there is no way to specify - should gas estimation happen on the latest or pending block.
Expected Behavior
Gas estimation should default to pending block as it's a more "correct" environment. There is no way transaction will get executed in the latest block as it's already mined.
Steps To Reproduce
contract BlockHashVerifier {
function verifyBlockHash(uint256 blockNumber, bytes32 providedHash) external view returns (bool isMatch) {
// blockhash only works for the 256 most recent blocks (excluding current)
require(block.number > blockNumber, "Block number must be less than current block");
require(block.number <= blockNumber + 256, "Blockhash unavailable for this block number");
bytes32 actualHash = blockhash(blockNumber);
assert(actualHash == providedHash);
}
}If you estimate gas for this contract setting blockTag to latest - it will fail. But it will succeed with pending.
There is no way to configure it from the level of writeContract, so a good default will help
Link to Minimal Reproducible Example
No response
Anything else?
No response
pociej and GodHermit
Metadata
Metadata
Assignees
Labels
No labels