Skip to content

Instantly share code, notes, and snippets.

@manabubannai
Created March 29, 2022 06:04
Show Gist options
  • Save manabubannai/06098ad55db491d3d0b80a8d92c75f4e to your computer and use it in GitHub Desktop.
Save manabubannai/06098ad55db491d3d0b80a8d92c75f4e to your computer and use it in GitHub Desktop.
// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0 <0.9.0;
contract donation {
address public owner;
constructor() {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner, "Not owner");
_;
}
struct Contributors {
uint id;
string name;
uint256 amount;
address sender_address;
}
uint256 id = 0;
mapping(uint => Contributors) public contributor;
function doDonation(string memory name) public payable {
id += 1;
contributor[id] = Contributors(id, name, msg.value, msg.sender);
}
function getBalance() public view returns(uint) {
return address(this).balance;
}
function withdrawMoney(address payable _to) public onlyOwner {
_to.transfer(getBalance());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment