码迷,mamicode.com
首页 > 其他好文 > 详细

Solidity智能合约调用智能合约

时间:2018-05-02 16:59:12      阅读:1661      评论:0      收藏:0      [点我收藏+]

标签:style   result   another   public   AC   chain   lin   block   rac   

来源: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智能合约调用智能合约

标签:style   result   another   public   AC   chain   lin   block   rac   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!