-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
💥 How to Compute the CREATE2
Deployment Address?
#140
Comments
CREATE2
Deployment Address?
Hey, so the address can be calculated correctly if you understand how the Lines 873 to 912 in 71925dd
Let's assume you use your own random If you really need to incorporate the // SPDX-License-Identifier: AGPL-3.0-only
pragma solidity 0.8.23;
import {CreateX} from "./CreateX.sol";
contract A is CreateX {
address internal constant _CREATEX = 0xba5Ed099633D3B313e4D5F7bdc1305d3c28ba5Ed;
function getDeployAddress(bytes32 salt, bytes32 initCodeHash) public view returns (address computedAddress) {
return CreateX(_CREATEX).computeCreate2Address(_guard(salt), initCodeHash);
}
} The code has been frozen long time ago and no changes will be applied to the |
CREATE2
Deployment Address?CREATE2
Deployment Address?
Describe the desired feature:
the
deployCreate2(salt,initCode)
generates a deterministic address for the target contract.But how can i get that address beforehand?
off-chain, I can do eth_call to get it, but on-chain (or foundry solidity script), we need a view function.
There is a view function
computeCreate2Address(salt,initCodeHash)
but it CANT be used:the reason is that deployCreate2 doesn't use the salt as-is, but "guard" it. even simple salt like "0" is replaced.
There is also on view function to calculate the guarded value.
Workaround
The following code can calculate the address in a script.
It has 2 shortcomings:
The text was updated successfully, but these errors were encountered: