1

If a function inside a contract calls another function in the same contract, is the msg.sender now the contract or still the original address that sent the initial transaction?

I know if contract A calls a function from contract B, the msg.sender is now contract A, but what about internally within 1 contract? does the msg.sender ever change? or is always the original tx sender?

2
  • it should stay the same, unless you are using this.functionName(..) to call that function.
    – Majd TL
    Commented Feb 17, 2022 at 15:47
  • 1
    to call an external function in your contract from your contract you need to use "this." and then it will change
    – Majd TL
    Commented Feb 17, 2022 at 16:00

1 Answer 1

1

Internally the msg.sender stays the same so caller of the function.

1
  • 1
    unless a function with external modifier with ("this") is called
    – Majd TL
    Commented Feb 17, 2022 at 16:05

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.