I've just completed building my first smart contract in Solidity and I am ready to deploy to the public.

I want to deploy to mainnet but I'm being told that I don't have enough funds to deploy. On the dry run it says the total cost is 0.00178154 ETH, around $4.

But on the actual deployment I get the following error from truffle:

"Migrations" could not deploy due to insufficient funds
   * Account:  <redacted>
   * Balance:  38271570000000000 wei
   * Message:  insufficient funds for gas * price + value

The wallet it's being deployed with has 0.0383 ETH (around $87) in it. Is this not enough to deploy a very small smart contract? If so, how much should it cost? This seems a little crazy if so.

Also here is the truffle-config.js...


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

module.exports = {
  networks: {
    development: {
      host: '',
      port: 7545,
      network_id: '*'
    mainnet: {
      provider: () => new HDWalletProvider({
        privateKeys: [process.env.PK],
        providerOrUrl: "https://mainnet.infura.io/v3/" + process.env.INFURA_PROJECT_ID
      network_id: 1
  contracts_directory: './contracts/',
  contracts_build_directory: './abis/',
  compilers: {
    solc: {
      optimizer: {
        enabled: true,
        runs: 200

The migrations contract is as follows:

pragma solidity >=0.4.21 <0.6.0;

contract Migrations {
  address public owner;
  uint public last_completed_migration;

  constructor() public {
    owner = msg.sender;

  modifier restricted() {
    if (msg.sender == owner) _;

  function setCompleted(uint completed) public restricted {
    last_completed_migration = completed;

  function upgrade(address new_address) public restricted {
    Migrations upgraded = Migrations(new_address);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.