# Deploying Using [create2crunch](https://github.com/0age/create2crunch) ## 1. Setup VastAI Follow template linked below for optimal GPU mining: - [Setup Instance](https://cloud.vast.ai/create/) - [Template with good requirements](https://cloud.vast.ai/?ref_id=75818&creator_id=75818&name=Template%20for%20efficient%20address%20farming) - [SSH Setup Instructions](https://vast.ai/docs/instance-setup/ssh) Once good, connect via SSH on the instance ## 2. Install Requirements ```bash curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh ``` ```bash . "$HOME/.cargo/env" \ sudo apt-get update \ sudo apt install build-essential ``` ```bash git clone https://github.com/0age/create2crunch.git ``` ## 3. Get Init Code Hash In Foundry project: ```solidity // Getting the init code hash bytes memory args = abi.encode(x,y); bytes memory bytecode = abi.encodePacked(type(CONTRACT).creationCode, args); console.logBytes32(keccak256(bytecode)); ``` ## 4. Run create2crunch On instance: ```bash cd create2crunch export FACTORY="0x0000000000ffe8b47b3e2130213b802212439497" export CALLER="<DEPLOYER_ADDRESS>" export INIT_CODE_HASH="<HASH_FROM_STEP_3>" cargo run --release $FACTORY $CALLER $INIT_CODE_HASH ``` ## 5. Deploy Contract In Foundry project: ```solidity interface ImmutableCreate2Factory { function safeCreate2(bytes32, bytes memory) external; } function run() public { vm.createSelectFork("mainnet"); vm.startBroadcast(deployer); ImmutableCreate2Factory factory = ImmutableCreate2Factory(0x0000000000FFe8B47B3e2130213B802212439497); bytes32 initalizeCode = keccak256(abi.encodePacked(type(CONTRACT).creationCode, abi.encode(ARGS))); console.logBytes32(initalizeCode); address expectedAddress = <ADDRESS_FROM_CREATE2CRUNCH>; bytes32 salt = bytes32(<SALT_FROM_CREATE2CRUNCH>); factory.safeCreate2( salt, abi.encodePacked(type(CONTRACT).creationCode, abi.encode(ARGS)) ); vm.stopBroadcast(); } ``` Notes: - Test deployment (command to deploy without `--broadcast` ) - Add require address deployed == expected