Question: transact() vs build_transaction()/sign_transaction() #1566
-
Hi there, I find myself confused about the difference between two methods to deploy an instance of a contract:
Both methods work perfectly fine in the SimpleStorage deployment example. However, I cannot understand why the second method works as well, without signing any transaction and not using the private key? When should one use which method and why? I found a similar question in the ethereum stackexchange: https://ethereum.stackexchange.com/questions/111893/whats-the-difference-between-transact-and-buildtransaction However, I'm not satisfied with the answer, since I never had to sign any transaction to deploy the contract. Would be very thankful for any answer that would clear my mind :) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hello @fulltimecrypto The At the end both ways end up using So yes, the only difference here is how the private key is managed, anyways on the further lesson you'll find that does no matter that much as we use frameworks like brownie which handles it differently. Cheers. |
Beta Was this translation helpful? Give feedback.
Hello @fulltimecrypto
Nice question, the answer you got on stack exchange is actually correct, but let me go in deep in to it.
Using
buildTransaction
is more a step to step process, Patrick used this approach to teach how all the process to create and sign transaction works, including you have direct control of the private_key, which is a variable you can use on the code or as an environment variable.The
transact
function requires the private key to be handled differently, most likely by the rpc client (metamask, ganache and so on).At the end both ways end up using
send_raw_transaction
, but transact does it more automatically.So yes, the only difference here is how the private key is m…