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?
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.