I'm getting the error:

"Migrations" could not deploy due to insufficient funds. Sender doesn't have enough funds to send tx. The upfront cost is: 45000000000000000 and the sender's account only has: 0

as I'm migrating into Rinkeby test network. I have enough ether in Account #2 from faucet that I'm trying to use, but Truffle is persistently trying to use Account #1 that has 0 balance in it. At which point does Truffle try to connect to MetaMask? Is it Node or Truffle that's not working properly? And how do I change the account that Truffle recognizes so that I can connect to Account #2, instead of Account #1?

So far, I've tried:

  1. Uninstalling and re-installing Truffle
  2. Logging out and re-logging into MetaMask and toggling between the accounts
  3. Changing the gas/gasPrice to a higher value or commenting them out
  4. Changing the node version

I'm using "@truffle/hdwallet-provider": "^1.0.35"

    rinkeby: {
      provider: () =>
        new HDWalletProvider(
      network_id: 4, // rinkeby's id
      gas: 4500000, // rinkeby has a lower block limit than mainnet
      gasPrice: 10000000000,
      confirmations: 2,
      timeoutBlocks: 200,
      skipDryRun: false,

To use accounts other than the first one you have to indicate so to HDWalletProvider. Third parameter is account index, default is 0. For example to use the fifth one:

provider: () => {
    return new HDWalletProvider(mnemonic, URL, 4);

If required you can indicate to load more than one account. To load the the first 5 accounts

provider: () => {
    return new HDWalletProvider(mnemonic, URL, 0, 5);

Truffle will use the first account returned from provider but you can change default account using from in truffle-config.js

  develop: {
    provider: () => {...},
    from: "0x01230123...0123",
    gas: "4500000",
    gasPrice: "10000000000",

You can also override default configuration passing new parameters when deploying

module.exports = function(deployer) {
  deployer.deploy(Migrations, {
    from: "0x444433332222....0000",
    gas: "1000000",
    gasPrice: "9000000000",
  1. Make sure you have enough eth in your migration account ( truffle uses account[0] on migrations ).

  2. I think your configuration is set to pay a ludicrous price for each gas uint but not allowing enough gas units to be spent for your transaction, either because the price is so large that you spend all your eth, or you set a low gas limit.

    Try removing the gas price option in your configuration, and set the gas to the network's block limit. Rinkeby seems to have a block limit of: gas: 5500000. If this doesn't solve it you will need to post at least the involved migration code.

  3. The error can change at this point if your smartcontract is too big to fit on a single transaction. You only have one option on a public network and it is to re-design your contract into many you can publish all your required logic.

  • 1
    Thank you for your response. I have enough ether in my one of my accounts. The error is that Truffle is accessing an account with 0 balance in it. Is there a way to change Truffle from accessing Account #1 to Account #2, which has the balance in it? None of the Truffle commands allow this. – Kevvv May 11 '20 at 22:01
  • The easiest way to do that is to fund that wallet that the truffle is using already using. However you can unlock another wallet. ethereum.stackexchange.com/questions/17441/… You could alternatively use web3 to post directly like this example. ethereum.stackexchange.com/questions/7255/… – ccolorado May 11 '20 at 23:39
  • You can use a different account by setting a 'from' address in your truffle.config. // from - default address to use for any transaction Truffle makes during migrations trufflesuite.com/docs/truffle/reference/configuration#networks – wslyvh May 12 '20 at 14:02

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.