pcaversaccio / createx

Factory smart contract to make easier and safer usage of the `CREATE` and `CREATE2` EVM opcodes as well as of `CREATE3`-based (i.e. without an initcode factor) contract creations.
https://createx.rocks
GNU Affero General Public License v3.0
303 stars 18 forks source link

💥 Compute Vanity Addresses #95

Closed JOY closed 6 months ago

JOY commented 6 months ago

Describe the desired feature:

Hi,

In the past, my developers employed Create2 to precompute the vanity address, with a pleasing format such as 0x9999... But it seems that we cannot do that with CreateX. Are we missing something or CreateX hasn't supported that feature yet?

Code example that solves the feature:

No response

pcaversaccio commented 6 months ago

You can compute the vanity addresses for CreateX using createXcrunch. Is this what you're looking for?

If you simply want to calculate the CREATE2 contract address, there are 2 functions in CreateX:

function computeCreate2Address(bytes32,bytes32) view returns (address)
function computeCreate2Address(bytes32,bytes32,address) pure returns (address)
JOY commented 6 months ago

Let us try CreateXCrunch and will update here

pcaversaccio commented 6 months ago

Let us try CreateXCrunch and will update here

You can deploy things like this 4 bytes zero leading contract https://etherscan.io/tx/0xd4f95266511547b6e7173a5a28614ce9a2374641fec79bee3720234bd9f03199#internal. So I think that's what you're searching for.

dienho12 commented 6 months ago

hi @pcaversaccio, we use CreateXCrunch get saft: 0xba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed01a34e9a3b1e51ff03e017bc => 0x7979a19d6613a4a95c76b82a47989c388fa126c7 and want deploy contract 0x7979a19d6613a4a95c76b82a47989c388fa126c7 on multi chain like dostest, fuji. But when i use createX deploy (createX[deployCreate2(bytes32,bytes)](salt, bytecode)) ) , i get different contract i want. https://test.doscan.io/tx/0xb32084b5ff12055058e7e36f2d7a40aa8f123bf2118a20a76d84406b1c763907. Please help me check it? Thank bro!

pcaversaccio commented 6 months ago

hi @pcaversaccio, we use CreateXCrunch get saft: 0xba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed01a34e9a3b1e51ff03e017bc => 0x7979a19d6613a4a95c76b82a47989c388fa126c7 and want deploy contract 0x7979a19d6613a4a95c76b82a47989c388fa126c7 on multi chain like dostest, fuji. But when i use createX deploy (createX[deployCreate2(bytes32,bytes)](salt, bytecode)) ) , i get different contract i want. https://test.doscan.io/tx/0xb32084b5ff12055058e7e36f2d7a40aa8f123bf2118a20a76d84406b1c763907. Please help me check it? Thank bro!

So in that case, the salt is again keccak256 hashed before invoking CREATE2. Please go through the special features we have built here: https://github.com/pcaversaccio/createx#permissioned-deploy-protection-and-cross-chain-redeploy-protection. In your case, the final salt used will be:

salt = keccak256(abi.encode(salt))

https://github.com/pcaversaccio/createx/blob/main/src/CreateX.sol#L910

pcaversaccio commented 6 months ago

@Dien-DOS I quickly checked your deployment transaction. createXcrunch cli already gives you the correct contract address (so you don't have to calculate it yourself) but you put the wrong salt. Compare the one you pasted here with the one in the transaction. They are not the same.

dienho12 commented 6 months ago

thank @pcaversaccio , We are trying your way! and will update here.

dienho12 commented 6 months ago

thank bro! problem is resolved! @pcaversaccio

pcaversaccio commented 6 months ago

thank bro! problem is resolved! @pcaversaccio

What was the bug?

dienho12 commented 6 months ago

saft i deploy wrong, fix salt = keccak256(abi.encode(salt))!

pcaversaccio commented 6 months ago

Ok, will close accordingly 👍