Why is it impossible to deploy a smart contract (to Mainnet) using Truffle?

1.6k Views Asked by At

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.

0

There are 0 best solutions below