@@ -6,21 +6,29 @@ import "forge-std/Vm.sol";
66import "src/BatchCallAndSponsor.sol " ;
77import "lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol " ;
88import "lib/openzeppelin-contracts/contracts/utils/cryptography/MessageHashUtils.sol " ;
9+ import "lib/openzeppelin-contracts/contracts/utils/Create2.sol " ;
910
1011contract DeployBatchCaller is Script {
1112 BatchCallAndSponsor public batchCaller;
13+ // This salt will be used for CREATE2 deployment
14+ bytes32 public constant SALT = keccak256 ("BatchCallAndSponsor-v1 " );
1215
1316 function run () external {
1417 uint256 deployerPk = vm.envUint ("DEPLOYER_KEY " );
15- address deployer = vm. addr (deployerPk);
16- console. log ( " Deployer: " , deployer) ;
18+ // Get the bytecode of the contract
19+ bytes memory bytecode = type (BatchCallAndSponsor).creationCode ;
1720
1821 // Start broadcasting transactions with Alice's private key.
1922 vm.startBroadcast (deployerPk);
2023
21- // Deploy the delegation contract (Alice will delegate calls to this contract).
22- batchCaller = new BatchCallAndSponsor ();
24+ // Deploy using CREATE2
25+ address payable deployedAddress = payable (Create2.deploy (0 , SALT, bytecode));
26+
27+ // Cast the deployed address to BatchCallAndSponsor
28+ batchCaller = BatchCallAndSponsor (deployedAddress);
2329
2430 vm.stopBroadcast ();
31+ // Log the deployed address
32+ console2.log ("BatchCallAndSponsor deployed to: " , deployedAddress);
2533 }
2634}
0 commit comments