PasswordPusher icon indicating copy to clipboard operation
PasswordPusher copied to clipboard

Explain difference between `tx.origin` and `msg.sender`.

Open DavidBDiligence opened this issue 3 years ago • 1 comments

In the tx.origin page it would be helpful to include short background information on what tx.origin is and how it differs from msg.sender.

DavidBDiligence avatar Sep 09 '22 20:09 DavidBDiligence

The tx.origin global variable refers to the original external account that started the transaction while msg.sender refers to the immediate account (it could be external or another contract account) that invokes the function. The tx.origin variable will always refer to the external account while msg.sender can be a contract or external account.

If there are multiple function invocations on multiple contracts, tx.origin will always refer to the account that started the transaction irrespective of the stack of contracts invoked

for more information cheak this https://learning.oreilly.com/library/view/solidity-programming-essentials/9781788831383/3d3147d9-f79f-4a0e-8c9f-befee5897083.xhtml#:~:text=The%20tx.,account)%20that%20invokes%20the%20function.

thanks, A K.

AnandK-2024 avatar Sep 13 '22 13:09 AnandK-2024