When using truffle to migrate smart contracts to Ganache it selects the first address to send the contract and also decrements the gas cost from this address.

How does truffle 'know' to select this address/account? It doesn't seem to be specified anywhere.

Also can it be changed?

2 Answers 2


Truffle uses the first account it finds when it inspects the "wallet" which has 10 accounts set up, per ganache's default setup.

According to the docs, it's possible to change behavior.

You can optionally pass an array of contracts, or an array of arrays, to speed up deployment of multiple contracts. Additionally, the last argument is an optional object that can include the key named overwrite as well as other transaction parameters such as gas and from. If overwrite is set to false, the deployer won't deploy this contract if one has already been deployed. This is useful for certain circumstances where a contract address is provided by an external dependency.


Hope it helps.

  • Thanks - so this is just a kinda nice to have quick solution for testing, in prod, it wouldn't just look at your first account in Geth and use that would it?
    – Woodstock
    Sep 12, 2018 at 15:11
  • 1
    Yes, it would. It would deploy from the first account, by default. Sep 12, 2018 at 15:45

Truffle dont need to know this. This is setting of gancahe testrpc chain as taking the first account as default one.

  • Ok thanks - but where is it communicated which address to decrement. Surely when moving to production this needs to be specified?
    – Woodstock
    Sep 12, 2018 at 14:58
  • 1
    Yes in the production; we dont usually unlock account like this. We will use private key to sign the tnx
    – Tony Dang
    Sep 12, 2018 at 15:00

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.