Solidity gyakorlatozgatások
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

71 lines
2.2 KiB

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.11;
contract Donatetocontract{
uint256 public sendernumber = 0;
uint256 public minmoney = 0;
uint256 public amountwithdrawed = 0;
uint256 public nrofwithdraw = 0;
string internal message;
uint256 private amountearned = 0;
address private admin;
uint256 private monthlycosts = 30000;
mapping (uint256 => address) internal showaddress;
mapping (uint256 => string) internal showmessage;
mapping (uint256 => uint256) internal showmoney;
constructor() {
admin = 0x4B20993Bc481177ec7E8f571ceCaE8A9e22C02db;
}
address payable[] public donators;
function getdonators() public view returns (address payable[] memory){
return donators;
}
function senddonation(string memory _message) public payable{
require(msg.value > minmoney, 'Please do not donate 0 amount!');
sendernumber = sendernumber + 1;
amountearned = amountearned + msg.value;
showaddress[sendernumber] = msg.sender;
message = _message;
showmessage[sendernumber] = message;
showmoney[sendernumber] = msg.value;
donators.push(payable(msg.sender));
}
function adminWithdraw(uint256 _withdrawamount) public returns (bool) {
require(msg.sender == admin, 'You are not the central admin!');
(bool sent,) = msg.sender.call{value: _withdrawamount}("");
amountwithdrawed = amountwithdrawed + _withdrawamount;
return sent;
}
function _showsender(uint256 _sendernumber) public view returns (address cim_ , uint256 osszeg_, string memory uzenet_) {
return (showaddress[_sendernumber], showmoney[_sendernumber], showmessage[_sendernumber]);
}
function _showcontract() public view returns (uint nrofDonation_, uint amountEarned_, uint amountWithdrawed_, uint currentTotal_){
return (sendernumber, amountearned, amountwithdrawed, address(this).balance);
}
function _monthlyresults () private view returns(uint256) {
return amountearned - monthlycosts;
}
function showbalance() public view returns (uint256) {
return address(this).balance;
}
}