0
votes

I am trying to deploy a test contract on Ropsten network. I am using metamask, infura and truffle to create and test the contract. My folder structure looks like this

My folder structure looks like this

My migration file has following codes

const TestContract = artifacts.require("TestContract");

module.exports = function(deployer) {
  deployer.deploy(TestContract);
};

When i run truffle migrate i am getting following error Could not find artifacts for Migrations from any sources

My truffle-config.js look like this

    const HDWalletProvider = require('truffle-hdwallet-provider')
module.exports = {
    networks: {
        ropsten: {
            provider: function() {
                return new HDWalletProvider("Mnemonic key", "https://ropsten.infura.io/v3/API_KEY")
            },
            network_id: 3,
            gas: 4000000
        }
    },
    contracts_directory: './src/contracts/',
    contracts_build_directory: './src/abis/',
    compilers: {
        solc: {
            optimizer: {
                enabled: true,
                runs: 200
            }
        }
    }
}
1

1 Answers

0
votes

You need to have Migrations contract in your contracts folder:

pragma solidity >=0.4.25 <0.6.0;

contract Migrations {
  address public owner;
  uint public last_completed_migration;

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

  constructor() public {
    owner = msg.sender;
  }

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

  function upgrade(address new_address) public restricted {
    Migrations upgraded = Migrations(new_address);
    upgraded.setCompleted(last_completed_migration);
  }
}

Also a 1_initial_migration.js in your migrations folder:

const Migrations = artifacts.require("Migrations");

module.exports = function(deployer) {
  deployer.deploy(Migrations);
};