Created
February 4, 2020 10:33
-
-
Save nolim1t/3a8b419e3adbdda6712b5af7959ac475 to your computer and use it in GitHub Desktop.
External Solidity Contract Calling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.11; | |
contract TokenPrototype { | |
function transfer(address to, uint256 value) public returns (bool) {} | |
function name() public view returns (string) {} | |
} | |
contract Client { | |
TokenPrototype _t; // We can see the transfer function | |
function Client(address serviceAddress) { | |
_t = TokenPrototype(serviceAddress); // _t will be the "TokenPrototype" located at serviceAddress | |
} | |
function send(address to, uint256 value) public returns(bool) { | |
return _t.transfer(to, value); // message/response to Service is intuitive | |
} | |
function getname() public view returns (string) { | |
return _t.name(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment