Repository navigation
Contract has non-empty code in body of a script but not in a constructor of another contract #11691
Replies: 1 comment
|
Reproduced on
Both phases use the same sender ( Logging
That is what breaks your script. The Two ways around it1. Pass the RPC on the command line instead of forking inside forge script script/Counter.s.sol --rpc-url $MAINNET_RPCfunction run() public {
vm.startBroadcast(); // no vm.createSelectFork
address counter = address(new Counter());
new HasNonEmptyCode(counter);
vm.stopBroadcast();
}2. If you need vm.createSelectFork(getChain("mainnet").rpcUrl);
(, address sender, ) = vm.readCallers();
vm.resetNonce(sender); // vm.setNonce can't lower a nonce
vm.startBroadcast();Both pass on 1.8.3. Note Worth an issue in its own right, I think: the divergence is silent, and it only surfaces when a deployed address is captured into calldata. Anything that records an address during execution — constructor args, |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I am encountering a very strange issue. I have
The result:
The error message indeed corresponds to the require:
Aka, it seems to be ✅ working for a local empty simulation, but ❌ not for a local forking simulation. I have
MAINNET_RPC_URLset correctly to a correct endpointI have pushed the code: https://github.com/hacker-DOM/foundry-issue-empty-contract-in-after-deployment-in-script/blob/a478aad33d66469349b18a8a48b4cf5adbd9eee7/script/Counter.s.sol#L23.
All reactions