Truffle – Fix Migrations Running Out of Gas on Mainnet

mainnetout-of-gastruffletruffle-migration

I trying to deploy my contract but I cant. After deployed in ropsten and development, for some reason I can't deploy to mainnet.

Truffle v5.3.3 (core: 5.3.3)

deploying…

enter image description here

after

enter image description here

compilers

compilers: {
    solc: {
      version: "0.8.0",
      // docker: true,
      settings: {
       optimizer: {
         enabled: true,
         runs: 1000
       },
      }
    }
  },

mainnet config

mainnet: {
        provider: () => new HDWalletProvider(mnemonic, `https://mainnet.infura.io/v3/xxxxx`),
        network_id: 1,
        gas: 5000000,
        gasPrice: 5e9,
        // confirmations: 2,
        from: 'xxx',
        // timeoutBlocks: 200,
        skipDryRun: true
    },

My question is: how much gas do I need to put and how many blocks will be counted to deploy? At 57 the truffles broke, how much do you need to deploy?

EDIT

I deploy to ropsten and works. But mainnet not.

enter image description here

Best Answer

You need your gasPrice to be much higher. 1 Gwei is 1e9, and these days 60-100 gwei are "normal" gas prices. Often even more is needed. See here for current gas prices.

Related Topic