Caller -> Contract B -> Contract A
Contract A has a msg.sender variable.
I want to use the Caller as Msg.Sender for Contract A through Contract B.
How is this done?
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.
Sign up to join this communityCaller -> Contract B -> Contract A
Contract A has a msg.sender variable.
I want to use the Caller as Msg.Sender for Contract A through Contract B.
How is this done?
There are only two common variables for finding out senders. There´s msg.sender
which gives address of the one who sent/relayed the current transaction call - so the previous contract or EOA (Externally Owned Account) in the chain of contract calls. Then there´s tx.origin
which is the original issuers of the transaction - always an EOA, never a contract as a contract can't issue a new transaction. Typically tx.origin
is very seldom needed and shouldn't be used. In your case tx.origin
gives what you want but I suggest to rethink your design so you wouldn't need that.
msg.sender
explicitly - that comes from the environment.
Jul 28, 2019 at 15:58