Posts

Showing posts with the label #Donation

"Donation Contract" Example

Image
So in this Post i will be writing a Donation Contract. The idea is, The Creator Creates the contract. another person wants to Donate a certain amount of Ether to the Creator. Warning: Tests done with Remix, i can be the creator and send ether to myself without deduction of my own ether. (Im not sure why it allows this.) ideally if i dont have enough ether, it has to revert back, but it doesnt.  (Please help me by commenting Below) pragma solidity ^0.4.0; contract DonationAresh { address creator; //this is Aresh function DonationAresh() public{ creator = msg.sender; } //fall back function that gets an amount of ether and sends to Creator function () payable public{ safeMoney(msg.value); } //send the amount to the creator function safeMoney(uint amountRaised) private{ creator.send(amountRaised); } } So from the Remix IDE there are 5 Accounts. im using the first account as the Creator of the Contr...