-
-
Save manabubannai/06098ad55db491d3d0b80a8d92c75f4e to your computer and use it in GitHub Desktop.
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
// 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