4

I am trying to deploy my contract but it returns this error

truffle migrate --network ropsten --reset

1_initial_migration.js
======================

   Deploying 'Migrations'
   ----------------------
Error: Error: Error:  *** Deployment Failed ***

"Migrations" -- sender account not recognized.

truffle_config.js

ropsten: {
      provider: function() {
          return new HDWalletProvider(mnemonic, "https://ropsten.infura.io/v3/<PROJECTID>")
      },
      network_id: "*", 
      gas: 4000000,
      from: "0x4e2f89...."
    }
Gelso77
  • 1,763
  • 6
  • 30
  • 47

1 Answers1

3

By default, the HDWalletProvider will use the address of the first address that's generated from the mnemonic. If you pass in a specific index, it'll use that address instead.

So if you are using address that isn't the first address from this mnemonic you should ether specify the address

HDWalletProvider(mnemonic, "ropsten.infura.io/v3/<PROJECTID>", indexOfYourAddress)

or unlock multiple addresses by putting number to the forth parameter

HDWalletProvider(mnemonic, "ropsten.infura.io/v3/<PROJECTID>",0, numberOfAddresses)
Vitaly Migunov
  • 4,297
  • 2
  • 19
  • 23