Difference between tx.origin and msg.sender

Careful readers might have noticed in the previous code illustration that both tx.origin and msg.sender show the same result and output. 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. However, msg.sender will refer to ...

Get Solidity Programming Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.