Picture taken from the solidity language docs- Introduction of smart contracts page

I would like to clear my doubt that when caller and called contract are same. Then the memory will get a new initialization right? or is it a different case.

1 Answer 1


You can call your own contract's external functions (recursively) by this.functionName. If you inspect msg.sender in that subsequent call, the result is the that contract's address. Since it's an external call, a new memory range is allocated.

Here's an example:

pragma solidity ^0.8.0;
contract A {
    event Addr(address);

    function myA() view external returns (address) {
        return msg.sender;

    function test() public {
        emit Addr(this.myA());

If you call the function test, you see it emits the same contract address.

Your Answer

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

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