Skip to content

Commit

Permalink
created script to deploy modified TWCloneFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
GWSzeto committed Nov 27, 2024
1 parent a842cbb commit 4458c70
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions script/superchain/DeployTWCloneFactory.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
pragma solidity ^0.8.20;

import {Script} from "forge-std/Script.sol";
import "lib/forge-std/src/console.sol";
import {TWCloneFactory} from "src/TWCloneFactory.sol";
import {SuperChainInterop} from "src/module/token/crosschain/SuperChainInterop.sol";

interface ICreateX {

function deployCreate2(bytes32 salt, bytes memory initCode) external returns (address newContract);

}

contract DeployTWCloneFactoryScript is Script {

address createX = 0xba5Ed099633D3B313e4D5F7bdc1305d3c28ba5Ed;

function deployDeterministic(bytes32 salt, bytes memory creationCode) public returns (address) {
address deployedAddress;

// Deploy using CREATE2
assembly {
deployedAddress := create2(0, add(creationCode, 0x20), mload(creationCode), salt)
}

require(deployedAddress != address(0), "CREATE2 failed");

return deployedAddress;
}

function run() external {
uint256 testPrivateKey = vm.envUint("DEPLOYER_PRIVATE_KEY");
vm.startBroadcast(testPrivateKey);

bytes32 salt;
bytes memory initCode = abi.encodePacked(type(TWCloneFactory).creationCode);

address twCloneFactory = ICreateX(createX).deployCreate2(salt, initCode);
console.log("TWCloneFactory deployed: ", twCloneFactory);

vm.stopBroadcast();
}

}

0 comments on commit 4458c70

Please sign in to comment.