solidity官方时间库:https://github.com/pipermerriam/ethereum-datetime 

solidity语言是一个合约调用另外一个主网的合约的方法(接口声明调用)

一个如何调用主网智能合约的方法案例!(此案例用Rinkeby测试网络部署)

这里接口的作用:只是用来声明需要调用的方法!

一个如何调用主网智能合约的方法案例!


pragma solidity >=0.5.0 <0.7.0;

interface DateTime {
    function getDay(uint timestamp) view external returns (uint16);
}

contract Collection {
    // 必须把当前合约部署的网络和0x92482Ba45A4D2186DafB486b322C6d0B88410FE7同一个网络
    DateTime time = DateTime(0x92482Ba45A4D2186DafB486b322C6d0B88410FE7);
    uint target = 100 ether;
    uint percentage = 1;
    uint16 private datatime;

    constructor() public {

    }

    function() external payable{
        // 这里实现代币自动兑换
    }
    
    function test_time() public view returns(uint16){
        return time.getDay(1554710705);
    }
}

参考别人的分析:https://blog.csdn.net/lj900911/article/details/83037691

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-21
  • 2022-12-23
  • 2022-12-23
  • 2021-05-31
  • 2022-12-23
  • 2021-06-08
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-25
相关资源
相似解决方案