首页 > 其他 > 详细

Solidity智能合约调用智能合约

时间:2018-05-02 16:47:17      阅读:217      评论:0      收藏:0      [点我收藏+]

来源:https://medium.com/@blockchain101/calling-the-function-of-another-contract-in-solidity-f9edfa921f4c

合约一:

pragma solidity ^0.4.18;
contract Deployed {
    uint public a = 1;
    
    function setA(uint _a) public returns (uint) {
        a = _a;
        return a;
    }
    
}

 

合约二调用合约一:

pragma solidity ^0.4.18;
contract Deployed {
    
    function setA(uint) public returns (uint) {}
    
    function a() public pure returns (uint) {}
    
}
contract Existing  {
    
    Deployed dc;
    
    function Existing(address _t) public {
        dc = Deployed(_t);
    }
 
    function getA() public view returns (uint result) {
        return dc.a();
    }
    
    function setA(uint _val) public returns (uint result) {
        dc.setA(_val);
        return _val;
    }
    
}

 

Solidity智能合约调用智能合约

原文:https://www.cnblogs.com/huahuayu/p/8981068.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!