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.
UPDATE
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?