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

0

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.

Gothenburg answered 27/2, 2021 at 0:22 Comment(8)
If you can deploy to testnet, but not mainnet, it is obviously gas price and block production problem.Commando
Also there are alternatives to Truffle that provide better developer experience: hardhat.org/guides/truffle-migration.htmlCommando
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!Gothenburg
Update: I've switched to Hardhat and it works. Truffle support looked into it and nothing was resolved. Oh well..Gothenburg
Glad that I could be some of the help even though cannot resolve Truffle issues.Commando
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..Gothenburg
It has been the same for the last five years, so if the history is the predictor of the future the answer is no.Commando
any updates? I stuck in the same problem...Brahmani

© 2022 - 2024 — McMap. All rights reserved.