简体   繁体   中英

Solidity function returning true in remix but false in web3 function call

I have this Solidity function, it is returning the right answer when called in remix IDE but in web3 call, it is returning false always

function checkSubscribed() public view returns(bool){
        if(block.timestamp>subscriptionPeriod[msg.sender]){
            return false;
        }
        else{
             return true;
        }
     
    }

My web3 call function(version 1.2.9)

myContract.methods.checkSubscribed().call({from:userAccount},(err,status)=>{
   console.log(status);

});

Deployed on kovan testnet

Check subscriptionPeriod[msg.sender] and block.timestamp .

If you don't know where to look at the timestamp value, just add a debug method to the contract:

function timestamp() external view returns (uint256) {
  return block.timestamp;
}

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