Skip to content

Instantly share code, notes, and snippets.

@nolim1t
Created February 4, 2020 10:33
Show Gist options
  • Save nolim1t/3a8b419e3adbdda6712b5af7959ac475 to your computer and use it in GitHub Desktop.
Save nolim1t/3a8b419e3adbdda6712b5af7959ac475 to your computer and use it in GitHub Desktop.
External Solidity Contract Calling
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