Skip to content

Instantly share code, notes, and snippets.

/-

Created September 29, 2017 13:58
Show Gist options
  • Save anonymous/373a3bb6d74a852e4a2cbdc5e76e0d29 to your computer and use it in GitHub Desktop.
Save anonymous/373a3bb6d74a852e4a2cbdc5e76e0d29 to your computer and use it in GitHub Desktop.
pragma solidity ^0.4;
contract BigSpender {
uint writeToMe;
function writes(uint){
writeToMe = 1; // this throws if gas given is less than 20k
}
}
contract ThingDoer {
BigSpender bigSpender = new BigSpender();
function anotherWay(){
if(!address(bigSpender).call(bytes4(sha3('writes(uint256)')), 1)){
// if the external call fails because OOG, we'll return
return;
}
else {
// if the external call succeeds, we'll throw
throw;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment