Skip to content

Instantly share code, notes, and snippets.

@Exulansis
Created January 17, 2018 13:34
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 Exulansis/1ff29774957cac4b32271d624a88fec0 to your computer and use it in GitHub Desktop.
Save Exulansis/1ff29774957cac4b32271d624a88fec0 to your computer and use it in GitHub Desktop.
A sample example of a Ethereum Smart Contract for managing donated funds.
pragma solidity ^0.4.19;
contract Donation {
address owner;
event fundMoved(address _to, uint _amount);
modifier onlyowner { if (msg.sender == owner) _; }
address[] _giver;
uint[] _values;
event deployed(address _a, address _creator);
function Donation() public {
owner = msg.sender;
// reverseRegistrar.claim(msg.sender)
deployed(this, msg.sender);
}
function donate() payable public {
addGiver(msg.value);
}
function moveFund(address _to, uint _amount) onlyowner public {
if (_amount <= this.balance) {
if (_to.send(this.balance)) {
fundMoved(_to, _amount);
} else {
revert();
}
} else {
revert();
}
}
function addGiver(uint _amount) internal {
_giver.push(msg.sender);
_values.push(_amount);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment