diff --git a/OP hazi.sol b/OP hazi.sol new file mode 100644 index 0000000..4826252 --- /dev/null +++ b/OP hazi.sol @@ -0,0 +1,55 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +pragma solidity ^0.8.11; + +contract winfreemoney { + + address public admin; + address payable[] public participants; + + event info( + uint256 date + ); + + constructor(){ + admin = msg.sender; + } + + + function freeBalance() public view returns (uint256){ // összes pénz + + return address(this).balance; + } + + function getparticipants() public view returns (address payable[] memory){ + + return participants; + } + + + function participate() external payable{ //neve és address-e a belépőnek + require(msg.value > .1 ether); //0.1 ether belépési dij + participants.push(payable(msg.sender)); + emit info(block.timestamp); // aktualis idöpont + } + + function randomnumber() private view returns (uint256){ // random szám generátor + + return uint256(keccak256(abi.encodePacked(admin, block.timestamp))); + } + + function yourwinner () public { + require(msg.sender == admin); // csak az admin használhatja + uint256 index = randomnumber() % participants.length; // nyertes választása + participants[index].transfer(address(this).balance); // transfer money + + participants = new address payable[](0); //reset the contract + + } + + function ertek () public pure returns (uint256){ // csak megadunk egy random értéket + + return 42; + } + + +} \ No newline at end of file