UUPS proxy smart contract #3225
-
Proxy contract contract TwitterProxy is ERC1967Proxy {
constructor(address implementation, bytes memory _data) payable ERC1967Proxy(implementation, _data) {
ERC1967Utils.changeAdmin(msg.sender);
}
} This was the test i was using function testProxyOwner() public view {
bytes32 constant ADMIN_SLOT = bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1);
bytes32 ownerAddressInBytes32 = vm.load(address(twitterProxy), ADMIN_SLOT);
address ownerAddress = address(uint160(uint256(ownerAddressInBytes32)));
assertEq(ownerAddress, deployedWithAccount);
} i was deploying using foundry and have given anvil first private key which has public address as - 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 , but i was getting the adminAddress as this - 0x1804c8AB1F12E6bbf3894d4083f33e07309d1f38 , which i came to know the Foundry default sender i don't know why i was seeing difference in the admin address as i was setting it with the msg.sender in the constructor |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hello @18121A05L2, any transaction in your script which is not wrapped inside |
Beta Was this translation helpful? Give feedback.
Hello @18121A05L2, any transaction in your script which is not wrapped inside
vm.startBroadcast()
andvm.stopBroadcast()
will be sent by theFoundry default sender
address which is0x1804c8AB1F12E6bbf3894d4083f33e07309d1f38
so to prevent theFoundry default sender
from being the msg.sender wrap the line that deploys the contract insidevm.startBroadcast()
andvm.stopBroadcast()
and pass the private key of the address you want to use as the sender insidevm.startBroadcast()
like thisvm.startBroadcast(privateKey)