Created
January 17, 2018 13:34
-
-
Save Exulansis/1ff29774957cac4b32271d624a88fec0 to your computer and use it in GitHub Desktop.
A sample example of a Ethereum Smart Contract for managing donated funds.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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