You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to replicate the functionality of Hardhat's ethers.provider.getTransactionCount(address) in Foundry. Here's the context:
addresspublic player;
function setUp() public {
player =address(0x1);
}
function testAABB() public {
_internal();
// After calling _internal(), we need to verify the transaction countassertEq(vm.getNonce(player), 1); // Ensure that the player's address sends exactly 1 transaction
}
The _internal function can contain any logic and utilize any cheat codes, including:
vm.startBroadcast(any address);
vm.stopBroadcast();
vm.prank(any address);
vm.stopPrank();
The _internal() function can contain various cheat codes and must be written by the developer. This means I cannot modify the function directly to fix the nonce issue.
The primary goal is to ensure that the player sends only one transaction. The solution needs to work within this constraint.
It's crucial that we prevent any bypass of the assertEq condition.
I'm facing challenges because the developer can write arbitrary code within the _internal function, potentially affecting the transaction count. Any insights or suggestions on how to effectively enforce the transaction count constraint would be greatly appreciated!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi everyone,
I'm trying to replicate the functionality of Hardhat's
ethers.provider.getTransactionCount(address)
in Foundry. Here's the context:The
_internal
function can contain any logic and utilize any cheat codes, including:vm.startBroadcast(any address);
vm.stopBroadcast();
vm.prank(any address);
vm.stopPrank();
It's crucial that we prevent any bypass of the
assertEq
condition.I'm facing challenges because the developer can write arbitrary code within the
_internal
function, potentially affecting the transaction count. Any insights or suggestions on how to effectively enforce the transaction count constraint would be greatly appreciated!Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions