msg.sender not working on web wallet calls

  • Hello,

    For some reason, whenever I use "msg.sender" in a smart contract, it doesn't capture the sender address properly if I'm calling it from the web wallet.

    msg.sender is returning 0xffffffffffffffffffffffffffffffffffffffff

    Does anyone know about that?


  • Hello @paulofelipe84,

    I think this is more of a problem understanding the EVM and Solidity than a wallet problem.

    Contract calls from the web wallet are reading the local state database, there is not a msg.caller because there is no transaction.

    If you send to contract (send a transaction that can change the contract’s variables) there will be a sender.

    Take a look at this contract:

    pragma solidity >= 0.5.1 < 0.6.0; 
    contract GetLastSender{
        address lastSender;  // the last address to call this contract (could be another contract or a contract call)
        // get the last caller - not a transaction, no gas required 
        function getTheLastCaller() public view returns (address) {
            return lastSender;
        // set the last sender - transaction, requires gas
        function setTheLastSender() public {
            lastSender = msg.sender;  // save each time contract receives a transaction    

    Compile and publish this contract.

    Then use this sequence:

    1. Call the contract with method getTheLastSender. It will return 00000000… (initialized to zero, I think).

    2. Send to the contract with method setTheLastSender. This will set the variable lastSender.

    3. Call the contract again with method getTheLastSender. It will return the a 40 character hex address (padded with zeros) of the sender from step 2. Use a Core wallet command like “fromhexaddress” to convert from the a raw hex address to a base 58 pubkeyhash address (“Q” address).

    For more information about using the web wallet with smart contracts see

  • @jb395 Thanks for your answer! It's been a while, so I'm not sure if that was actually my mistake to expect a msg.sender on contract calls, or if I just couldn't express myself properly.

    Anyway, the algorithm eventually worked.

    Thanks again!

Log in to reply