I've been developing a smart contract for a while on the Ropsten network using the Truffle framework, quite successfully. My truffle-config.js looks like this:

const path = require("path");
const HDWalletProvider = require('@truffle/hdwallet-provider');

module.exports = {
  contracts_build_directory: path.join(__dirname, "client/src/contracts"),
  networks: {
    develop: {
      port: 8545,
      network_id: "*",
      host: ""
    ropsten: {
      provider: new HDWalletProvider(mnemonic, ropsten),
      network_id: 3,
      gas: 4000000 
    "live": {
      provider: new HDWalletProvider(mnemonic, mainnet),
      network_id: 1,
      gas: 5000000
  compilers: {
    solc: {
      version: "^0.6.0"

Where "mnemonic" and "ropsten" are strings connecting to my account and to my Infura link respectively.

I believe it is time to deploy my smart contract to the Mainnet. After looking for a little while for ways to do this within the Truffle framework, I came upon the Truffle documentation:


I concluded that using network_id: 1 is how I get truffle migrate --network live to deploy my smart contracts to the Mainnet.

After running the aforementioned command with gas specified at 5000000 in the truffle-config.js, I get the following error:

Error:  *** Deployment Failed ***

"Migrations" -- transaction underpriced.

However, turning that up to 10000000, I get the following error:

"Migrations" could not deploy due to insufficient funds
   * Account:  0xffA1c53b18d864A6340adA628BdFF6651fa4E097
   * Balance:  111432174000000000 wei
   * Message:  insufficient funds for gas * price + value
   * Try:
      + Using an adequately funded account
      + If you are using a local Geth node, verify that your node is synced.

What do you think is happening here? Is there some golden spot between 5000000 and 10000000 I should be looking for, and if so, how can I know beforehand what it is? Or is there something else I'm missing?

1 Answer 1


Inside the networks section, update your truffle-config.js with something like:

gasPrice: 470000000000,

In truffle-config.js, gas refers to the maximum amount of gas you are willing to pay for the deployement of your smart contract.

Let's assume you contract costs 8 000 000 gas. With the current average gas price of 40 Gwei, the total deployement cost will be 8M * 40 = 320000000 Gwei = 320000000000000000 wei > 111432174000000000 wei (your account balance) .

When deploying to the mainnet you should always fix the gas price by yourself using a "gasPrice" field in your truffle-config.

  • Is it then correct that the deployment of a contract like this, under the current rates of Ether, could cost over $70?
    – Eric
    Jul 19, 2020 at 12:13
  • Yes, the Ethereum network is overloaded and the gas price is very high since a few months.
    – clement
    Jul 19, 2020 at 12:16

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.