házi feltöltöltése
parent
92d1c64322
commit
0da6d551c9
|
@ -0,0 +1,115 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
pragma solidity ^0.8.11;
|
||||
|
||||
// visibility related kérdések:
|
||||
// az admin private de mégis az external functionnel le lehet kérni?
|
||||
// az amountearned private de internal functionnel lehet kérni?
|
||||
|
||||
|
||||
//egyéb kérdés:
|
||||
// van e olyan hogy listában (nem csak egyet) mutatja azokat akik már donate-oltak? Pl. address-t - array
|
||||
// hogy tudom egymásba foglalni a show the address és a show the message functionoket?
|
||||
|
||||
|
||||
contract Donatetocontract{
|
||||
uint256 public nrofdonate;
|
||||
uint256 public minmoney;
|
||||
uint256 public amountwithdrawed;
|
||||
uint256 public nrofwithdraw;
|
||||
string internal message;
|
||||
mapping (uint256 => address) internal showaddress;
|
||||
mapping (uint256 => string) internal showmessage;
|
||||
uint256 private amountearned;
|
||||
address private admin;
|
||||
uint256 private monthlycosts;
|
||||
|
||||
|
||||
constructor() {
|
||||
nrofdonate = 0;
|
||||
amountearned = 0;
|
||||
minmoney = 10;
|
||||
amountwithdrawed = 0;
|
||||
nrofwithdraw =0;
|
||||
admin = 0x9A0e3A6Dfc8E3C9Ba53d59C120898883d0Cee732;
|
||||
monthlycosts = 30000;
|
||||
|
||||
|
||||
}
|
||||
|
||||
function senddonation(uint256 _money, string memory _message) public payable{
|
||||
require(_money >= minmoney, 'Please donate more than one penny!');
|
||||
nrofdonate = nrofdonate + 1;
|
||||
amountearned = amountearned + _money;
|
||||
showaddress[nrofdonate] = msg.sender;
|
||||
message = _message;
|
||||
showmessage[nrofdonate] = message;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function adminWithdraw() internal returns (bool) {
|
||||
require(msg.sender == admin, 'You are not the central admin!');
|
||||
(bool sent,) = msg.sender.call{value: address(this).balance}("");
|
||||
return sent;
|
||||
|
||||
}
|
||||
|
||||
function _showtheaddress(uint256 _sendernumber) private view returns (address) {
|
||||
return showaddress[_sendernumber];
|
||||
}
|
||||
|
||||
function showtheaddress(uint256 _sendernumber) public view returns (address) {
|
||||
return showaddress[_sendernumber];
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------
|
||||
|
||||
function _showthemessage(uint256 _sendernumber) internal view returns (string memory) {
|
||||
return showmessage[_sendernumber];
|
||||
|
||||
}
|
||||
|
||||
function showthemessage(uint256 _sendernumber) public view returns (string memory) {
|
||||
return showmessage[_sendernumber];
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
function showtheadmin () external view returns (address) {
|
||||
return admin;
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
function donateearned () public view returns (uint256) {
|
||||
return amountearned;
|
||||
}
|
||||
|
||||
|
||||
function donatecount () public view returns (uint256) {
|
||||
return nrofdonate;
|
||||
}
|
||||
|
||||
|
||||
function _monthlyresults () private view returns(uint256) {
|
||||
return amountearned - monthlycosts;
|
||||
}
|
||||
|
||||
|
||||
function _donateearned () private view returns (uint256) {
|
||||
return amountearned;
|
||||
}
|
||||
|
||||
|
||||
function szam () public pure returns (uint256) {
|
||||
return 163;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//function showbalance() public view returns (address) {
|
||||
//return address(this).balance;
|
||||
//}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue