简体   繁体   中英

Why msg.sender has the address of the account which has deployed the contract (and not the one's which interacts with it)?

I am currently developing a dapp on ethereum. From what I know msg.sender should has the value of the account who interact with it. However, it keeps the value of the deployer's account.

I am using metamask and solidity ^0.4.24. I am deploying the contact using truffle framework and also Ganache GUI as my virtual node

function getMe() public view returns(address){
        return msg.sender;
    }

So, I expect this code to return the hash of the account which is interacting with the contract but instead I am taking back the address of the acount which deployed it

msg.sender contains the value of the address of the caller. You must be deploying and interacting from the same account, probably using accounts[0] .

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM