to be
a problem slover

use solidity to deploy contract

contract Foo {
    constructor(address _owner) public {
        owner = _owner;
    }
    // other functions
}

contract Deploy {
    function deploy(bytes32 salt) external returns (address){
        return address(new TxnSender{salt : salt}($owner_address));
    }
}

Context

Salt must be byte32,if use remix to pass the salt, it is looks like

0x81ab92dd3a944ae29ec86e46c4e891b3ef3078f446cd88c56edd342542c3a8cc

By use this method, you can deploy Foo contract with a specific address, for example address with leading zeros 0x0000000.

赞(4) 打赏
欢迎转载,注明出处:刘世明的博客 » use solidity to deploy contract

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

觉得文章有用就打赏一下作者

支付宝扫一扫打赏

微信扫一扫打赏