知乎专栏 | 多维度架构 |
在合约中调用一个已经存在的合约。
pragma solidity ^0.4.24; /******************************************/ /* Netkiller Crowdsale Contract */ /******************************************/ /* Author netkiller <netkiller@msn.com> */ /* Home http://www.netkiller.cn */ /* Version 2018-06-07 - Solc ver: 0.4.24 */ /******************************************/ interface token { function balanceOf(address _address) constant external returns (uint256); function transfer(address receiver, uint amount) external; } contract Netkiller { token public tokenContract; constructor(address addressOfToken) public { tokenContract = token(addressOfToken); } function getBalance(address _address) view public returns (uint256){ return tokenContract.balanceOf(_address); } function transfer(address _to, uint256 _value) payable public{ tokenContract.transfer(_to, _value); } }