简体   繁体   English

Solidity function 在混音中返回真,但在 web3 function 调用中返回假

[英]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我有这个 Solidity function,它在 remix IDE 中调用时返回正确答案,但在 web3 调用中,它总是返回 false

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)我的 web3 调用函数(1.2.9 版)

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

});

Deployed on kovan testnet部署在 kovan 测试网上

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

If you don't know where to look at the timestamp value, just add a debug method to the contract:如果你不知道在哪里查看timestamp值,只需在合约中添加一个调试方法即可:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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