Skip to content

Instantly share code, notes, and snippets.

@Andromelus
Created May 1, 2018 06:12
Show Gist options
  • Save Andromelus/df8d070562e4a4818d99fac6792af8ba to your computer and use it in GitHub Desktop.
Save Andromelus/df8d070562e4a4818d99fac6792af8ba to your computer and use it in GitHub Desktop.
pragma solidity ^0.4.22;
// Florian CASTELAIN <castelainflorian44@gmail.com> 10/02/2018
// Only signatures of the already deployed contract
// The equivalent of the ABI when using web3
// This is an abstract contract used to generate the needed ABI. The EVM does it itself
// --- WE REQUIRE THIS ONLY IF WE WANT TO INCLUDE PRECALCULATED ABI ---
contract target {
function setValue(string v) public;
}
contract executer {
target public tc;
address public ta;
// - USE THIS WITH PRECALCULATED ABI --
function exeWithAbi(string value) public {
tc.setValue(value);
}
function setAddress(address a) public {
//Create instance of the target contract with it's address
tc = target(a);
ta = a;
}
// This is if we don't have the ABI.
// keccak256 allows to create the function signature
// WARNING: Here we use the address and not the sig of the contract
//-- USE THIS WITHOUT PRECALCULTED ABI / THE ABSTRACT ON TOP IS NOT REQUIRED --
function exeWithoutAbi(string v) public {
require(ta.call(bytes4(keccak256("setValue(string)")),abi.encode(v)));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment