If Contract A tells Contract B to do something, and then Contract B tells Contract C to do something, whose address will Contract C always see as the very first sender?
When an External Owned Account (EOA), which is a user's wallet controlled by a private key, initiates a transaction on the blockchain, this EOA is considered the original transaction initiator. Inside any smart contract function that executes as part of this transaction, there are two important global variables related to the sender: `tx.origin` and `msg.sender`.
`tx.origin` is a global variable that always represents the address of the External Owned Account (EOA) that initiated the entire transaction. This value remains constant throughout the entire transaction execution, regardless of how many smart contracts call each other in a chain. It is the very first sender that signed the transaction.
`msg.sender` is a global variable that represents the address of the immediate caller of the current smart contract. Its value changes with each internal message call within a transaction.
Let's apply this to the given scenario:
1. An External Owned Account (EOA) initiates a transaction by calling Contract A.
2. Inside Contract A, `msg.sender` is the EOA's address, and `tx.origin` is also the EOA's address.
3. Contract A then makes an internal message call to Contract B.
4. Inside Contract B, `msg.sender` is Contract A's address (because Contract A was its immediate caller), but `tx.origin` remains the EOA's address (because the EOA initiated the entire transaction).
5. Contract B then makes an internal message call to Contract C.
6. Inside Contract C, `msg.sender` is Contract B's address (because Contract B was its immediate caller).
However, the question asks for the address of the "very first sender." In this sequence, the very first sender of the entire transaction is always the External Owned Account (EOA) that initiated it. Therefore, Contract C will always see the address of the original External Owned Account (EOA) that initiated the transaction as the very first sender, accessible through the `tx.origin` global variable.