Skip to content

Commit

Permalink
feat: add deployment and creation scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
dyedm1 committed Sep 27, 2023
1 parent 15105f7 commit 7c0e56c
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
32 changes: 32 additions & 0 deletions script/Create4Deployed.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.20;

import "forge-std/Script.sol";
import {Create4Factory} from "src/Create4Factory.sol";

/**
* @title Deploys the code present at `env.DEPLOYED_CODE_ADDRESS` with `env.DEPLOYED_CODE_SALT` through the canonical Create4Factory using the deployed code method from `addr(env.DEPLOYER_PRIVATE_KEY)`
* @notice Only functional on networks with EIP-3855 support
* @author dyedM1
*/
contract Create4Deployed is Script {
function run() public {
uint256 DEPLOYER_PRIVATE_KEY = vm.envUint("DEPLOYER_PRIVATE_KEY");
bytes memory INIT_CODE = vm.envBytes("INIT_CODE");
bytes32 DEPLOYED_CODE_SALT = vm.envBytes32("DEPLOYED_CODE_SALT");

// Temporary Sepolia deployment; NOT FINAL!
Create4Factory C4F = Create4Factory(payable(0x33A92AB4eBdf13D4D12E4bb0009c6CF7730e76d2));

vm.startBroadcast(DEPLOYER_PRIVATE_KEY);

address deployedCode;
assembly {
deployedCode := create(0, add(INIT_CODE, 0x20), mload(INIT_CODE))
}

C4F.create4(deployedCode, DEPLOYED_CODE_SALT);

vm.stopBroadcast();
}
}
27 changes: 27 additions & 0 deletions script/Create4Transient.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.20;

import "forge-std/Script.sol";
import {Create4Factory} from "src/Create4Factory.sol";

/**
* @title Deploys `env.DEPLOYED_CODE` with `env.DEPLOYED_CODE_SALT` directly through the canonical Create4Factory using the transient storage method from `addr(env.DEPLOYER_PRIVATE_KEY)`
* @notice Only functional on networks with EIP-1153 & EIP-3855 support
* @author dyedM1
*/
contract Create4Transient is Script {
function run() public {
uint256 DEPLOYER_PRIVATE_KEY = vm.envUint("DEPLOYER_PRIVATE_KEY");
bytes memory DEPLOYED_CODE = vm.envBytes("DEPLOYED_CODE");
bytes32 DEPLOYED_CODE_SALT = vm.envBytes32("DEPLOYED_CODE_SALT");

// Temporary Sepolia deployment; NOT FINAL!
Create4Factory C4F = Create4Factory(payable(0x33A92AB4eBdf13D4D12E4bb0009c6CF7730e76d2));

vm.startBroadcast(DEPLOYER_PRIVATE_KEY);

C4F.create4(DEPLOYED_CODE, DEPLOYED_CODE_SALT);

vm.stopBroadcast();
}
}
21 changes: 21 additions & 0 deletions script/DeployC4Factory.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.20;

import "forge-std/Script.sol";
import {Create4Factory} from "src/Create4Factory.sol";

/**
* @title Deploys an instance of Create4Factory
* @author dyedM1
*/
contract DeployC4Factory is Script {
function run() public {
uint256 DEPLOYER_PRIVATE_KEY = vm.envUint("DEPLOYER_PRIVATE_KEY");

vm.startBroadcast(DEPLOYER_PRIVATE_KEY);

new Create4Factory();

vm.stopBroadcast();
}
}

0 comments on commit 7c0e56c

Please sign in to comment.