Can I deploy a contract in Solidity (not in-line assembly) using create2?


Yes. Solidity version 0.6.2 introduced a high-level way to use the create2 opcode. From the release docs:

When creating a contract, you can specify the salt as a "function call option": new Contract{salt: 0x1234}(arg1, arg2)

As an example, the following deploy() function will deploy the Test contract using a salt of 0x1234 and a constructor param of 123.

pragma solidity 0.6.2;

contract Test {
    uint256 public a;
    constructor (uint256 _a) public {
        a = _a;

contract DeployTest {
    function deploy() public {
        new Test{salt: 0x1234}(123);

Yes. Solidity version 0.6.2 you can do it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.