Skip to content

Instantly share code, notes, and snippets.

Created August 9, 2022 21:59
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
pragma solidity ^0.8.0;
contract Donation {
// input your default donor address
address public donor = 0x5B38Da6a701c568545dCfcB03FcB875f56beddC4;
uint constant DONATION_FEE = 2 ether;
modifier onlyDonor() {
require(msg.sender == donor,"Only buyer can call this.");
function setNewDonor(address _donor, address _recipient) public payable onlyDonor {
uint bal = address(this).balance;
uint amount = msg.value;
if (msg.value < DONATION_FEE) revert("Not enough Ether provided.");
// Perform the buy operation.
donor = _donor;
assert(address(this).balance == bal - amount);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment