I have runned ganache-cli with this command:

$ ganache-cli --port 8545 --gasLimit 12000000 --accounts 10 --hardfork istanbul --mnemonic test

I have create a truffle project with this command:

$ truffle unbox react

A sample smartcontract is generated in contracts/SimpleStorage.sol

I have tried to deploy this contract on ganache with this command:

$ truffle migrate

I did not made any configuration of HDWallet in truffle-config.js

It is strange but the deployment worked ! I want to understand how this can be possible. gas fees for contract deployment were payed by the first ganache-cli account. I am wondering how his can be possible because truffle didn't know the mnemonic and the accounts private keys.

I just want to understand

Thanks for your help.

  • This question does not have enough information about Truffle, your account setup, etc. to try to guess how it is possible. I suggest you simply use a JavaScript debugger to find out how Truffle has a private key for the account you think it does not have. Jan 29, 2021 at 11:55
  • i have detailled see my edit
    – Bob5421
    Jan 29, 2021 at 12:44

1 Answer 1


Since ganache has all accounts unlocked truffle gets the accounts with getAccounts and uses the first one when sending transactions. Similarly with gas prices it calls getGasPrice.

Truffle is never aware of HDWallet. It assumes it is talking with an ethereum client. HDWallet hooks the provider and intercept some calls to ensure the transactions are signed and valid accounts are returned by getAccounts.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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