[Ethereum] truffle migrate –network ropsten issues

dappsganachetruffletruffle-contracttruffle-migration

When i run truffle migrate --network ropsten i don't see the contract deployment but just

Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.

i don't know why but also deleting ./build i can't see the deploying of my migrations files but only

Compiling your contracts...
===========================
> Compiling ./contracts/A.sol
> Compiling ./contracts/B.sol
> Artifacts written to /Users/........./build/contracts
> Compiled successfully using:
   - solc: 0.5.0+commit.1d4f565a.Emscripten.clang

A lot of guides show a code like this:

Running migration: 1_initial_migration.js
Deploying Migrations…
… 0xd01dd7...
Migrations: 0xf741...
Saving successful migration to network…
… 0x78ed...
Saving artifacts…
Running migration: 2_deploy_contracts.js
Deploying HelloWorld…
… 0x0aa9...
HelloWorld: [SAVE THIS ADDRESS!!]
Saving successful migration to network…
… 0xee95...
Saving artifacts…

And here my truffle.js code:

var HDWalletProvider = require("truffle-hdwallet-provider");
const MNEMONIC = 'my mnemonic words from metamask'

module.exports = {
  // See <http://truffleframework.com/docs/advanced/configuration>
  // for more about customizing your Truffle configuration!
  networks: {
    development: {
      host: "127.0.0.1",
      port: 7545,
      network_id: "*" // Match any network id
    },

    ropsten: {
      provider: function() {
        return new HDWalletProvider(MNEMONIC, "ropsten.infura.io/v3/my-key")
      },
      network_id: 3,
      gas: 4000000      //make sure this gas allocation isn't over 4M, which is the max
    }
  }
};

So how can i solve this problem?

Best Answer

In truffle.js (or truffle-config.js) under the ropsten provider, try passing the Infura API URL with https://. So it should look like this:

// Inside truffle.js
  ...

module.exports = {
  networks: {

      ...

    ropsten: {
      provider: function() {
        return new HDWalletProvider(MNEMONIC, "https://ropsten.infura.io/v3/my-key")
      },
      network_id: 3,
      gas: 4000000      //make sure this gas allocation isn't over 4M, which is the max
    }
  }
};
Related Topic