4

I am trying to deploy my smart contract to the main net using the following code:

truffle.js:

module.exports = {
  networks: {
    live: {
      provider: new HDWalletProvider("mnemonic from metamask", "https://mainnet.infura.io/<infuraKey>"),
      network_id: 1, // Main net
    }
  }
};

However, when executing truffle migrate --network live, I get the following error:

Error encountered, bailing. Network state unknown. Review successful transactions manually.
insufficient funds for gas * price + value

Anyone an idea what causes this error? On the account I use on MetaMask I have 1ETH for deployment. I also tried to add a gas amount to the live network, but this did not solve the problem.

4
  1. Go here and generate a 12 word mnemonic, for "Coin" select ETH.
  2. Save the mnemonic (the 12 words), and, lower down the page, the first address (derivation path ending with 0) and private key somewhere safe.
  3. Transfer some ETH from your account to the one that corresponds to the mnemonic you just generated. You can import it into MetaMask with the private key and later return the unused ETH.
  4. Use this tutorial to deploy your smart contracts through truffle, of course don't forget to replace the mnemonic from the tutorial with the one you just generated.
  5. Adjust the Provider URL in the tutorial with your personal access URL you received in the mail from infura, also, in the network configuration of the code example of the tutorial, change "ropsten" to "mainnet".

then do truffle migrate --mainnet --dry-run (only available in v4beta, but a good habit) to check, if everything is fine, and then truffle migrate --mainnet.

EDIT: Of course you're also free to use the mnemonic from MetaMask.

  • Thanks! I now see that the account I imported was loose from MetaMask, meaning I was not backed by the seed phrase and therefore it could not migrate. (The account "did not exist" within the mnemonic. Creating a new account within MetaMask and transfering the funds worked. – guest7630763 Oct 18 '17 at 7:04

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.