0

I'm not sure I'm going in the right direction at all, so maybe you know totally different solution for deploying contract with vanity addresses?

My current approach is this:

  1. generate private key such that create contract with nonce = 0 will have vanity address
  2. fund this account with ETH
  3. deploy the contract

But I have a problem, my truffle migrations have 12 different contracts so I want to deploy only one of them using specific private key.

I managed to generate an ethereum private key which will create contract with desirable, let say 0x33333... address when CRATE with nonce 0:

"address":"0xad571ff7001055b9737826215548b3043a365e27",
"privKey":"b0c40801e0ef4e440541c2fa9e38f2e80297e8b73772d4fb8f7e361b3ee395f7",
"contract":"0x33333cea349b04af9cfe399a053203e3d70c2bba"

but if I do

module.exports = function(deployer, network, accounts) {
    deployer.then(async () => {
        await deployer.deploy(ContractA);
        // deploy many other contracts
        const privateKey = "b0c40801e0ef4e440541c2fa9e38f2e80297e8b73772d4fb8f7e361b3ee395f7";
        const accountCreate33333 = await web3.eth.accounts.privateKeyToAccount(privateKey);
        await deployer.deploy(ContractB, {from: accountCreate33333});
    });
}

returns the error: "ContractB" -- Returned error: sender account not recognized.

1

You can use HDWallet provider. It accepts an arrays with private keys as argument.

Then calling the deployer with { from: account } should just work (tm).

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.