This file contains 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.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; | |
payable(_recipient).transfer(amount); | |
assert(address(this).balance == bal - amount); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment