Skip to content

Instantly share code, notes, and snippets.

@D-Nice
Created October 14, 2017 22:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save D-Nice/6ef6e37e982340b177a4a14baf93249a to your computer and use it in GitHub Desktop.
Save D-Nice/6ef6e37e982340b177a4a14baf93249a to your computer and use it in GitHub Desktop.
contract Precompile {
function foo (bytes) returns (bytes32);
}
contract Testcontract {
bytes32 last;
event Debug(string message, bytes32 res);
Precompile prec = Precompile(0x0000000000000000000000000000000000000002);
function testMe () {
bytes memory s = "hello";
last = prec.foo("hello");
Debug("testMe()", last);
Debug("sha", sha256(s));
}
function test () returns (bytes32 b) {
string memory x = "hello";
bytes memory r;
uint len = bytes(x).length;
assembly {
let a := 0x0000000000000000000000000000000000000002
let v := 0
call(200000, a, v, add(x,0x20), len, r, 0x20)
pop
b := mload(r)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment