Skip to content

Instantly share code, notes, and snippets.

@ikumasa
Created March 1, 2017 15:48
Show Gist options
  • Save ikumasa/2984efb664b07ec0f271dd0bf676b12e to your computer and use it in GitHub Desktop.
Save ikumasa/2984efb664b07ec0f271dd0bf676b12e to your computer and use it in GitHub Desktop.
contract simplestorage {
uint public storedData;
event Set(address indexed sender, uint data);
function simplestorage(uint initVal) {
storedData = initVal;
}
function set(uint x) {
storedData += x;
Set(msg.sender, storedData);
}
function set2(uint x) payable {
storedData += x;
}
function get() constant returns (uint) {
return storedData;
}
}
contract simplestorage2 {
uint public storedData;
function set(uint x) {
storedData += x;
}
function set2(uint x) payable {
storedData += x;
}
function set3(address simpleAddr, uint x) {
simplestorage(simpleAddr).set(x);
}
function set4(address simpleAddr, uint x) {
simplestorage(simpleAddr).call.value(1)(bytes4(sha3("set2(uint256)")), x);
}
function get() constant returns (uint) {
return storedData;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment