Why msg.sender has the address of the deployer (address isnt the caller)

725 Views Asked by At

I'm currently developing on a simple Naming Service for the Ethereum Blockchain. msg.sender has the address of the deployer from the contract and not from the caller.

    address public caller;

      constructor() {
      caller = msg.sender;
   }

Using remix.ethereum.org and pragma solidity >=0.7.0 <0.9.0; and deployed on the JavaScript VM (London).

Can someone explain me why?

1

There are 1 best solutions below

0
On BEST ANSWER

Right now caller is going to be equal to the address that deployed the contract because that is what msg.sender will reference. If you are trying to make caller be the contract address instead, then you need to do caller = address(this);. address(this) is the actual contracts address.