From 0da6d551c9d6db071cf01e9a8b078bf2768de62b Mon Sep 17 00:00:00 2001 From: itsfine Date: Sun, 13 Feb 2022 17:32:38 +0100 Subject: [PATCH] =?UTF-8?q?h=C3=A1zi=20felt=C3=B6lt=C3=B6lt=C3=A9se?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Homework 1 Donate.txt | 115 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 Homework 1 Donate.txt diff --git a/Homework 1 Donate.txt b/Homework 1 Donate.txt new file mode 100644 index 0000000..d01be77 --- /dev/null +++ b/Homework 1 Donate.txt @@ -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; + //} + + +} \ No newline at end of file