[Ethereum] address(this) in solidity

blockchaincontract-debuggingremixsolidity

As per my understanding contract`s own address is the address which we assign to owner of contract using msg.sender.
But I saw this question on SE where it was described that a contract can access its own address using address(this) , but when i compiled following script

 address owner; 
function test (string _name)public view returns(bool){
  
    owner = msg.sender; 
    return owner == address(this);
}

i get boolean result as false.

So What is the difference between msg.sender and address(this).

Best Answer

this refers to the instance of the contract where the call is made (you can have multiple instances of the same contract).

address(this) refers to the address of the instance of the contract where the call is being made.

msg.sender refers to the address where the contract is being called from.

Therefore, address(this) and msg.sender are two unique addresses, the first referring to the address of the contract instance and the second referring to the address where the contract call originated from.