在Hradhat中可以轻松使用来实现代理 let proxy = await upgrades.deployProxy( ..... ) 这如何在Foundry Test里面实现?
hardhat的这个方法本质是上两个方法,一个是部署logic 一个是部署proxy, 用forge 两行搞定,给你个例子 contract CounterScript is Script { function setUp() public {}
function run() public {
uint256 deployerPrivateKey = vm.envUint("POLYGON_TEST_DEPOLY_PRIVATE_KEY");
vm.startBroadcast(deployerPrivateKey);
address admin = vm.envAddress("admin");
YourLogicContract impl = new YourLogicContract();
bytes memory data = abi.encodeWithSignature("initialize()");
YourProxyContract proxy = new YourProxyContract(address(impl), admin, data);
vm.stopBroadcast();
}
}