6

Why is deploying to Mainnet using Truffle so difficult?

Here is a rundown of trying to deploy to Mainnet...

  1. Current Gasprice is 110 Wei. Therefore 110000000000 wei

Let's plug that in..

mainnet: {
      provider: () =>
        new HDWalletProvider({
          mnemonic: { phrase: process.env.MNEMONIC },
          providerOrUrl: process.env.RPC_URL_1_WSS,
        }),
      network_id: 1, 
      from: process.env.DEPLOYERS_ADDRESS,
      gasPrice: 110000000000, /*  GAS PRICE!! */
      confirmations: 2,
      timeoutBlocks: 200,
      skipDryRun: false, public nets )
    },
  },
  1. Let's get the gas cost estimate of deploying. This will be set in gas parameter of truffle-config.

NODE_ENV=production truffle migrate --network mainnet --dry-run

Summary
=======
> Total deployments:   2
> Final cost:          0.001403824 ETH

0.001403824 ETH is $2.04.
So that's probably wrong.

‼️FAIL‼️


  1. Second try. Ok the dry run wasn't useful for getting gas estimates. I'll leave gas blank and try to deploy with just gasPrice.

Results in.. Message: insufficient funds for gas * price + value ‼️FAIL‼️

  1. Ok, I'm since the dry-run didn't give a useful estimate for what the contract costs to deploy, I'll just guess based on other contracts. Going to add the gas parameter here.
mainnet: {
      provider: () =>
        new HDWalletProvider({
          mnemonic: { phrase: process.env.MNEMONIC },
          providerOrUrl: process.env.RPC_URL_1_WSS,
        }),
      network_id: 1, 
      from: process.env.DEPLOYERS_ADDRESS,
      gasPrice: 110000000000, /*  GAS PRICE!! */
      gas: 140000000000000000, / That's about $200 in Wei/
      confirmations: 2,
      timeoutBlocks: 200,
      skipDryRun: false, public nets )
    },
  },

RuntimeError: abort(Error: Assertion failed). Build with -s ASSERTIONS=1 for more info..

‼️FAIL AGAIN‼️


  1. Third attempt. Ok, going to try to just leave gas and gasPrice blank..

Block timesout in 750 seconds.

‼️FAIL‼️


Trying on Remix..

  1. Set provider to Injected Web3
  2. Set network to Mainnet
  3. Deploy
  4. Cost $135

This is great, but now I'm not using Truffle's migrations, and it isn't as easy to use Remix ABI with Truffle.

I'm really really prefer Truffle to just work.

Why is Truffle sooooo difficult to use when deploying to Mainnet? It is impossible to deploy to Mainnet.

GN.
  • 8,672
  • 10
  • 61
  • 126
  • If you can deploy to testnet, but not mainnet, it is obviously gas price and block production problem. – Mikko Ohtamaa Mar 01 '21 at 10:09
  • 1
    Also there are alternatives to Truffle that provide better developer experience: https://hardhat.org/guides/truffle-migration.html – Mikko Ohtamaa Mar 01 '21 at 10:10
  • 2
    It is definitely problem. But the details to the question matter. The dry-run gives a gas estimate for deploy, using that AND the correct current gas price — it still fails. I'm literally plugging in the number it tell me to! – GN. Mar 01 '21 at 21:10
  • 2
    Update: I've switched to Hardhat and it works. Truffle support looked into it and nothing was resolved. Oh well.. – GN. Mar 04 '21 at 01:12
  • Glad that I could be some of the help even though cannot resolve Truffle issues. – Mikko Ohtamaa Mar 04 '21 at 10:36
  • No worries. Was in time crunch to launch it. Kind of frustrating because the project was 100% complete, but deploying to mainNet is totally stuck. I really like Truffle, hopefully the deployment process will improve in the future.. – GN. Mar 05 '21 at 01:07
  • 1
    It has been the same for the last five years, so if the history is the predictor of the future the answer is no. – Mikko Ohtamaa Mar 05 '21 at 10:45
  • any updates? I stuck in the same problem... – GIA Oct 28 '21 at 22:13

0 Answers0