0

I am trying to deploy 3 contracts to Avalanche. I have already deployed these same contracts to Ropsten, Rinkeby, and Ethereum mainnet.

When I try to deploy to Avalanche, I get this error message:

Error: *** Deployment Failed ***

"Migrations" ran out of gas (using Truffle's estimate.)

  • Block limit: 8000000 (0x7a1200)
  • Gas sent: NaN (0xNaN)
  • Try: Setting a higher gas estimate multiplier for this contract Making your contract smaller Making your contract constructor more efficient Setting a higher network block limit if you are on a private network or test client (like ganache).

If I set gas in truffle.config, it still fails no matter what I set. Even if I set the gas limit all the way up to the maximum for the block, it still fails.

For example, if I set it to 3000000, I get this:

Error: *** Deployment Failed ***

"Migrations" ran out of gas (using a value you set in your network config or deployment parameters.)

  • Block limit: 8000000 (0x7a1200)
  • Gas sent: 3000000 (0x2dc6c0)

Or if I set to 8000000, I get a similar message.

When I deployed to Rinkeby, it cost 2,460,214 units of gas. When I deployed to Ethereum mainnet, it cost 1,118,450 for the first two contracts.

Is there any way to fix this or should I just abandon Avalanche and deploy to some other network?

Here is my truffle.config file:

const Web3 = require("web3");
 const { projectUrl, mnemonicPhrase } = require('./secrets.json');
 const HDWalletProvider = require('@truffle/hdwallet-provider');
       const fs = require('fs');
 

module.exports = {
  /**
   * Networks define how you connect to your ethereum client and let you set the
   * defaults web3 uses to send transactions. If you don't specify one truffle
   * will spin up a development blockchain for you on port 9545 when you
   * run `develop` or `test`. You can ask a truffle command to use a specific
   * network from the command line, e.g
   *
   * $ truffle test --network <network-name>
   */

   
   contracts_build_directory: './admin-page/src/artifacts/',

  networks: {
    development: {
    host: "127.0.0.1",     // Localhost (default: none)
    port: 7545,            // Standard Ethereum port (default: none)
    network_id: "*",       // Any network (default: none)
    },

    rinkeby: {
      provider: function() { 
       return new HDWalletProvider(mnemonicPhrase, projectUrl);
      },
      network_id: 43114,
      gasPrice: 10000000000,
  },

  avalanche: {
    provider: function() { 
     return new HDWalletProvider(mnemonicPhrase, projectUrl);
    },
    network_id: 1,
    gas: 3000000,
    gasPrice: 50,
},


  },

  // Configure your compilers
  compilers: {
    solc: {
    version: "0.8.0",    // Fetch exact version from solc-bin (default: truffle's version)
      // docker: true,        // Use "0.5.1" you've installed locally with docker (default: false)
      settings: {          // See the solidity docs for advice about optimization and evmVersion
      optimizer: {
      enabled: false,   
      runs: 200
      },
      evmVersion: "byzantium"
      }
    }
  },



  db: {
    enabled: false
  },

};
3
  • try running it with optimizer enabled. Commented Jan 17, 2022 at 22:40
  • Unfortunately, I tried with optimizer and got the same error. Any other ideas? Commented Jan 17, 2022 at 22:49
  • that was my solution that worked for me last time, unfortunately i have no other ideas. Commented Jan 17, 2022 at 22:52

1 Answer 1

0

I had similar issue with Truffle v5.4.16 (except in my case it worked everywhere except on Mainnet) but after upgrading to Truffle v5.4.33 the issue seem to disappear.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.