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

评论 2

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
  1. #1

    Thanks for sharing. I read many of your blog posts, cool, your blog is very good.

    binance anm"alan4周前 (03-25)回复
  2. #2

    Your point of view caught my eye and was very interesting. Thanks. I have a question for you. https://www.binance.com/register?ref=IHJUI7TF

    binance2周前 (04-09)回复

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

支付宝扫一扫打赏

微信扫一扫打赏