|
What is the difference between msg.senderand tx.originand why is it dangerous to use tx.origin? |
Answered by
TatyOko28
Feb 8, 2025
Replies: 1 comment
|
msg.sender: Refers to the address that called the function (can be a contract or a user). Solution : Always use msg.senderto verify caller ID. |
0 replies
Answer selected by
Mercure28
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
msg.sender: Refers to the address that called the function (can be a contract or a user).
tx.origin: Refers to the address of the user who initiated the transaction (does not change, even if multiple contracts are called).
Problem withtx.origin : It exposes the contract to phishing attacks . An attacker can create a contract that calls your contract with tx.origin, thus exploiting the verification logic.
Solution : Always use msg.senderto verify caller ID.