0

As a newbie in this space, I'm just wondering how Truffle handles migrating contracts with the Truffle Migrate command—what does it use to sign those transactions? Does it use some wallet implementation? In my development environment, truffle.js is configured to connect to Ganache.

Hopefully, this question makes sense.

E. Rowlands
  • 127
  • 8

4 Answers4

0

It uses the first account, or the account described in truffle.js for a given network, or the account described in the actual deployer.deploy(... {from: account});

Hope it helps.

Rob Hitchens
  • 55,151
  • 11
  • 89
  • 145
0

Quick answer

It does not (need to) sign these transactions.

Long answer

Under the hood, Truffle uses Ganache to run a local Ethereum Blockchain. Ganache also generate 10 pre-funded addresses. Truffle uses the first of these addresses to migrate contracts. These addresses are "unlocked" by Ganache, which means we DON'T NEED to sign transactions from them. As a result, Truffle just specify the from field of the deployment transactions, but does not sign them.

Julien Klepatch
  • 574
  • 2
  • 5
  • This is incorrect. Truffle includes ganachi-cli that may or may not skip that step, but it also deploys to private networks, public testnets and mainnet using geth or parity nodes. It does have to sign transactions to do so. Unlocking and signing are not the same thing. Outside of ganache it is necessary to unlock accounts for everything to work precisely because truffle will be signing transactions from the accounts it finds in the node. – Rob Hitchens Feb 22 '19 at 00:12
  • 1
    Rob, your comment missed the point. Please re-read carefully the question: "...in my development environment, truffle.js is configured to connect to Ganache." We are talking of Truffle with Ganache here, not Geth or Parity. – Julien Klepatch Feb 23 '19 at 08:51
0

As said by Julien, if truffle is connected to Ganache then it uses first account to perform transaction which is already unlocked , which means no need to sign.

If truffle is connected to main-net or test net, truffles uses truffle-hdwallet-provider to store private key in local machine.

Found below article useful, it explain how truffle interacts with Rinkeby and send signed transaction.

https://kauri.io/article/cbc38bf09088426fbefcbe7d42ac679f/truffle:-smart-contract-compilation-and-deployment

Shahid Hussain
  • 253
  • 2
  • 9
0

It uses the first unlocked account found in the node. This being either Ganache or any private network. If there is not unlocked account, it will fail.