1

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?

2
  • The question is unclear. Please consider adding the relevant part of your code. Commented Jul 28, 2019 at 8:00
  • _allowed[msg.sender][spender] that's what I have under the main contract. I want to be able to have msg.sender be passed as the calling contract. Commented Jul 28, 2019 at 15:27

1 Answer 1

1

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.

2
  • I am unable to change the already uploaded contract's msg.sender variable. I can only write the calling contract differently. Commented Jul 28, 2019 at 15:28
  • You can't change the value of msg.sender explicitly - that comes from the environment. Commented Jul 28, 2019 at 15:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.