I set my infura endpoint and mnemonic to deploy the contract to the Rinkeby testnet. Like this below.

const infuraKey = process.env.INFURA_KEY
const test_mnemonic = process.env.TEST_MNEMONIC

networks: {
  rinkeby: {
    provider: () => new HDWalletProvider(test_mnemonic, `https://rinkeby.infura.io/v3/${infuraKey}`),
    network_id: 4,
    gas: 6900000,
    gasPrice: 10000000000,
    confirmations: 2,
    timeoutBlocks: 200,
    skipDryRun: true

My account[0] is 0xeA28Ab53fFF23859c64DB5BAaA64E466713Afae7, but when I try to deploy with this command truffle migrate --network rinkeby, it fails with this error like below.

Error: Error: Error:  *** Deployment Failed ***

"Migrations" could not deploy due to insufficient funds

* Account:  0x9416c8F57eddFeb491F2d728EEb13781662Ac606
* Balance:  0 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.

at Object.run (/Users/deleo/.nvm/versions/node/v12.13.0/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:96:1)
at processTicksAndRejections (internal/process/task_queues.js:93:5)

I've searched that if my mnemonic includes 0x9416c8F57eddFeb491F2d728EEb13781662Ac606, but it didn't. I have no idea why truffle keeps migrating with wrong account.


I've found that at truffle console (truffle console --network rinkeby), I typed web3.eth.getAccounts() and it showed that the first account is 0x9416c8F57eddFeb491F2d728EEb13781662Ac606. Why truffle migrate uses this default account after I set my mnemonic? And where is this default account set from? How could I set my config to use my mnemonic?


Please try this way for your config:

const HDWalletProvider = require("truffle-hdwallet-provider");

const providerFactory = network =>
  new HDWalletProvider(
    process.env.MNEMONICS || "", // Mnemonics of the deployer
    `https://${network}.infura.io/v3/${process.env.INFURA_KEY}`, // Provider URL => web3.HttpProvider

module.exports = {
  compilers: {
    solc: {
      version: "^0.5.5",
      optimizer: {
        enabled: true,
        runs: 200
  networks: {
    rinkeby: {
      provider: providerFactory("rinkeby"),
      network_id: 4,
      gas: 6900000,
      gasPrice: 10000000000 // 10 Gwei
  • Thank you for the suggestion, but the result is same.
    – Jung Chun
    Nov 14 '19 at 0:47
  • Hey @ALATh I've updated my question that I found something else. Could you see it again?
    – Jung Chun
    Nov 14 '19 at 1:01
  • Perfect that you found the solution!
    – AL ATh
    Nov 15 '19 at 1:16

I've figured it out! truffle-hdwallet-provider module was using it's account[0] from m/44'/1'/0'/0. But I was trying to use the account from m/44'/60'/0'/0 which is by mnemonic creator tool from BIP39. This was the reason.

  • could you elaborate? I run into the same problem but I don't understand what are the steps to figure this out Jan 24 '20 at 21:29
  • @Alessandro Solbiati What I did was send some ETH to address showed on web3.eth.getAccounts(). Mar 27 '21 at 2:13

To get all accounts: truffle develop --network YOUR_NETWORK

You need to collect the mnemonic showed on prompt and put it on truffle-configs in HDWalletProvider settings:

    const ropstenProvider = new HDWalletProvider({
  mnemonic: {phrase: "abc talent waste identify hawk way dolphin crunch maze destroy flock already"},
  providerOrUrl: "wss://ropsten.infura.io/ws/v3/..."});

After this, you're gonna need to add that "weird account" into your Metamask account. For this, copy the FIRST private key and paste on Metamask -> Import Account -> Private Key.

Now, you can go to a faucet and get some coins with your account already setted.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.