0age / create2crunch

A Rust program for finding salts that create gas-efficient Ethereum addresses via CREATE2.
MIT License
472 stars 83 forks source link

Failed parsing arguments: invalid length for initialization code hash argument #21

Closed smol-ninja closed 5 months ago

smol-ninja commented 5 months ago

I may be incorrectly generating the init code, but I am receiving the following error:

Failed parsing arguments: invalid length for initialization code hash argument

To reproduce:

$ forge init hello_foundry
$ cd hello_foundry

Edit Counter.s.sol to the following so it logs the creation code:

contract CounterScript is Script {
    function setUp() public {}

    function run() public {
        vm.broadcast();
        bytes memory creationCode = type(Counter).creationCode;
        console.logBytes(creationCode);
    }
}

Then when I run the following, it throws the above error.

$ cargo run --release 0x0000000000ffe8b47b3e2130213b802212439497 0x95222290dd7278aa3ddd389cc1e1d165cc4bafe5 0x608060405234801561001057600080fd5b5060f78061001f6000396000f3fe6080604052348015600f57600080fd5b5060043610603c5760003560e01c80633fb5c1cb1460415780638381f58a146053578063d09de08a14606d575b600080fd5b6051604c3660046083565b600055565b005b605b60005481565b60405190815260200160405180910390f35b6051600080549080607c83609b565b9190505550565b600060208284031215609457600080fd5b5035919050565b60006001820160ba57634e487b7160e01b600052601160045260246000fd5b506001019056fea264697066735822122010f3077836fb83a22ad708a23102f2b487523767e1afef5a93c614619001648b64736f6c63430008170033

Any idea what I am doing wrong?

smol-ninja commented 5 months ago

I've figured it out. It has to be keccak256 of type(Counter).creationCode.