欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

cita与eth的兼容性

程序员文章站 2022-07-13 10:11:21
...

eth与cita时间戳精度不一样,有个配置项可以选择
eth_compatibility : 是否与以太坊兼容的开关(CITA默认与以太坊在块的时间戳精度上不兼容,CITA为毫秒,以太坊为秒)。

pragma solidity 0.4.26;

contract Nervosbj {
  uint public h = 1 hours;
  uint public min = 1 minutes;
  uint public s = 1 seconds;

  function timeNow ()
    public
    view
    returns (uint)
  {
    return block.timestamp;
  }

  function happyTime()
    public
    view
    returns (uint, uint, uint)
  {
    uint now = block.timestamp;
    return (now+s, now+min, now+h);
  }

}

参考:
https://docs.citahub.com/zh-CN/cita/configuration/service-config

转载于:https://www.jianshu.com/p/2c314a27f5a6