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.

-1

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.

  • 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 - B9lab Feb 22 at 0:12
  • 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 at 8:51
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.

  • And it signs the transaction using the accounts private key like any other transaction? – E. Rowlands Dec 1 '18 at 18:59
  • Right. Setting aside ganache-cli, the node could be plain old geth and it would know the difference. The "client" (truffle) signs the transaction. – Rob Hitchens - B9lab Dec 1 '18 at 19:25
  • oops ... "would not know the difference ;-)" - welcome. – Rob Hitchens - B9lab Dec 1 '18 at 19:45
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

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.