//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f. pragma solidity ^0.4.18; contract CodeRunner { address otherContract; function setOtherContract(address _otherContract) public { otherContract = _otherContract; } function callWithKnownFunction() public { // Here we cast the other contract to a "Target" and then call "foo" on it. Target(otherContract).foo(); } function callWithCall() public returns (bool){ // Now we don't know what kind of contract the other contract is // We're just blindly firing off a call to run a function we hope is there bytes4 hashOfFunctionToCall = bytes4(keccak256("foo()")); bool success = otherContract.call(hashOfFunctionToCall); return success; } } contract Target { uint _callCount = 0; function foo() public { _callCount += 1; } function callCount() public view returns (uint) { return _callCount; } }
0.4.18