- Contract name:
- LMNLotto
- Optimization enabled
- false
- Compiler version
- v0.6.12+commit.27d51765
- EVM Version
- default
- Verified at
- 2022-04-05T19:44:20.440121Z
Constructor Arguments
00000000000000000000000000000000000000000000000000000000000186a000000000000000000000000005888965fefcb8b35c55cb459cc0e06855a4454100000000000000000000000080138646decc9de9e066bc0cf03eb1dfafafde51
Arg [0] (uint256) : 100000
Arg [1] (address) : 0x05888965fefcb8b35c55cb459cc0e06855a44541
Arg [2] (address) : 0x80138646decc9de9e066bc0cf03eb1dfafafde51
Contract source code
// File: contracts/LMNLotto.sol pragma solidity ^0.6.12; contract LMNLotto { string public tokenName = "LMN Lotto"; string public tokenSymbol = "LMNX"; address public winner; uint256 public maxTickets; uint256 public remaingTickets; uint256 public ticketCount = 0; uint256 public randomNum; uint256 public endTime = 1652565600; // Sun May 15 2022 00:00:00 GMT+0200 (Central Europe Time) address public latestWinner; uint256 public lmnLottoPot; address[] public tickets; address payable public lemonFeeComi; address payable public governance; mapping(address => uint256) public winnings; mapping(address => uint) public purchasedTickets; constructor( uint256 _maximumTickets, address payable _lemonFeeComi, address payable _governance ) public { maxTickets = _maximumTickets; remaingTickets = _maximumTickets; lemonFeeComi = _lemonFeeComi; governance = _governance; } function buy1() public payable { require(block.timestamp <= endTime, "LMN Lotto is Closed"); require(msg.value == 1000000000000000000); //! 1 EWT uint256 val = msg.value / 1000000000000000000; require(ticketCount + val <= maxTickets, "No more LMN Lotto Tickets"); remaingTickets -= val; lmnLottoPot += msg.value; purchasedTickets[msg.sender] = purchasedTickets[msg.sender] +val; tickets.push(msg.sender); ticketCount++; } function buy5() public payable { require(block.timestamp <= endTime, "LMN Lotto is Closed"); require(msg.value == 5000000000000000000); //! 5 EWT uint256 val = msg.value / 1000000000000000000; require(ticketCount + val <= maxTickets, "No more LMN Lotto Tickets"); remaingTickets -= val; lmnLottoPot += msg.value; purchasedTickets[msg.sender] = purchasedTickets[msg.sender] +val; for(uint256 i = 0 ; i < 5; i++){ tickets.push(msg.sender); ticketCount++; } } function buy10() public payable { require(block.timestamp <= endTime, "LMN Lotto is Closed"); require(msg.value == 10000000000000000000); //! 10 EWT uint256 val = msg.value / 1000000000000000000; require(ticketCount + val <= maxTickets, "No more LMN Lotto Tickets"); remaingTickets -= val; lmnLottoPot += msg.value; purchasedTickets[msg.sender] = purchasedTickets[msg.sender] +val; for(uint256 i = 0 ; i < 10; i++){ tickets.push(msg.sender); ticketCount++; } } function buy20() public payable { require(block.timestamp <= endTime, "LMN Lotto is Closed"); require(msg.value == 20000000000000000000); //! 20 EWT uint256 val = msg.value / 1000000000000000000; require(ticketCount + val <= maxTickets, "No more LMN Lotto Tickets"); remaingTickets -= val; lmnLottoPot += msg.value; purchasedTickets[msg.sender] = purchasedTickets[msg.sender] +val; for(uint256 i = 0 ; i < 20; i++){ tickets.push(msg.sender); ticketCount++; } } function withdrawUser() public { require(block.timestamp > endTime, "LMN Lotto is not finished"); require(winnings[msg.sender] > 0); uint256 amountToWithdraw = winnings[msg.sender]; amountToWithdraw *= 1000000000000000000; uint256 lemonFee = (amountToWithdraw * 2) / 10; amountToWithdraw = amountToWithdraw - lemonFee; lemonFeeComi.transfer(lemonFee); msg.sender.transfer(amountToWithdraw); winnings[msg.sender] = 0; } function withdrawOwner(address payable winnerAddress) public { require(msg.sender == governance, "Not Allowed"); require(block.timestamp > endTime, "LMN Lotto is not finished"); require(winnings[winnerAddress] > 0); uint256 amountToWithdraw = winnings[winnerAddress]; amountToWithdraw *= 1000000000000000000; uint256 lemonFee = (amountToWithdraw * 2) / 10; amountToWithdraw = amountToWithdraw - lemonFee; lemonFeeComi.transfer(lemonFee); winnerAddress.transfer(amountToWithdraw); winnings[winnerAddress] = 0; } function chooseWinner() public { require(msg.sender == governance, "Not Allowed"); require(ticketCount > 0); randomNum = uint256(blockhash(block.number - 1)) % ticketCount; latestWinner = tickets[randomNum]; winner = latestWinner; winnings[latestWinner] = ticketCount; ticketCount = 0; remaingTickets = maxTickets; delete tickets; } function ticketsLength() external view returns (uint256) { return tickets.length; } function withdrawEthers(uint256 _amount) public { require(msg.sender == governance, "Not Allowed"); governance.transfer(_amount); } }
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"uint256","name":"_maximumTickets","internalType":"uint256"},{"type":"address","name":"_lemonFeeComi","internalType":"address payable"},{"type":"address","name":"_governance","internalType":"address payable"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"buy1","inputs":[]},{"type":"function","stateMutability":"payable","outputs":[],"name":"buy10","inputs":[]},{"type":"function","stateMutability":"payable","outputs":[],"name":"buy20","inputs":[]},{"type":"function","stateMutability":"payable","outputs":[],"name":"buy5","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"chooseWinner","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"endTime","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address payable"}],"name":"governance","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"latestWinner","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address payable"}],"name":"lemonFeeComi","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"lmnLottoPot","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"maxTickets","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"purchasedTickets","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"randomNum","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"remaingTickets","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"ticketCount","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"tickets","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"ticketsLength","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"tokenName","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"tokenSymbol","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"winner","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"winnings","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdrawEthers","inputs":[{"type":"uint256","name":"_amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdrawOwner","inputs":[{"type":"address","name":"winnerAddress","internalType":"address payable"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdrawUser","inputs":[]}]
Deployed ByteCode
0x60806040526004361061014b5760003560e01c80639917594c116100b6578063d84201bf1161006f578063d84201bf14610592578063dfbf53ae1461059c578063e31ce419146105dd578063ea3a1499146105e7578063f42067061461064c578063f630aa65146106875761014b565b80639917594c146104a25780639b894703146104e3578063abcbb55f1461050e578063b8cfc41214610525578063cd38aa8714610550578063cfbd900f146105675761014b565b80634fddee4b116101085780634fddee4b1461028657806350b44712146102b15780635aa6e675146103165780636c02a931146103575780637b61c320146103e757806381326191146104775761014b565b806304b1af751461015057806306ef53e01461015a5780630cd9f2711461019b578063127cae37146101a55780633197cbb61461020a5780633f0cea3f14610235575b600080fd5b6101586106b2565b005b34801561016657600080fd5b5061016f610908565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6101a361092e565b005b3480156101b157600080fd5b506101f4600480360360208110156101c857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610b83565b6040518082815260200191505060405180910390f35b34801561021657600080fd5b5061021f610b9b565b6040518082815260200191505060405180910390f35b34801561024157600080fd5b506102846004803603602081101561025857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ba1565b005b34801561029257600080fd5b5061029b610e89565b6040518082815260200191505060405180910390f35b3480156102bd57600080fd5b506102ea600480360360208110156102d457600080fd5b8101908080359060200190929190505050610e8f565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561032257600080fd5b5061032b610ecb565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561036357600080fd5b5061036c610ef1565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103ac578082015181840152602081019050610391565b50505050905090810190601f1680156103d95780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156103f357600080fd5b506103fc610f8f565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561043c578082015181840152602081019050610421565b50505050905090810190601f1680156104695780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561048357600080fd5b5061048c61102d565b6040518082815260200191505060405180910390f35b3480156104ae57600080fd5b506104b7611033565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156104ef57600080fd5b506104f8611059565b6040518082815260200191505060405180910390f35b34801561051a57600080fd5b5061052361105f565b005b34801561053157600080fd5b5061053a611283565b6040518082815260200191505060405180910390f35b34801561055c57600080fd5b50610565611290565b005b34801561057357600080fd5b5061057c6114e1565b6040518082815260200191505060405180910390f35b61059a6114e7565b005b3480156105a857600080fd5b506105b161173c565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6105e5611762565b005b3480156105f357600080fd5b506106366004803603602081101561060a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061199d565b6040518082815260200191505060405180910390f35b34801561065857600080fd5b506106856004803603602081101561066f57600080fd5b81019080803590602001909291905050506119b5565b005b34801561069357600080fd5b5061069c611ae4565b6040518082815260200191505060405180910390f35b60075442111561072a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f4c4d4e204c6f74746f20697320436c6f7365640000000000000000000000000081525060200191505060405180910390fd5b6801158e460913d00000341461073f57600080fd5b6000670de0b6b3a7640000348161075257fe5b049050600354816005540111156107d1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f4e6f206d6f7265204c4d4e204c6f74746f205469636b6574730000000000000081525060200191505060405180910390fd5b806004600082825403925050819055503460096000828254019250508190555080600e60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401600e60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060005b601481101561090457600a339080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506005600081548092919060010191905055508080600101915050610879565b5050565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6007544211156109a6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f4c4d4e204c6f74746f20697320436c6f7365640000000000000000000000000081525060200191505060405180910390fd5b678ac7230489e8000034146109ba57600080fd5b6000670de0b6b3a764000034816109cd57fe5b04905060035481600554011115610a4c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f4e6f206d6f7265204c4d4e204c6f74746f205469636b6574730000000000000081525060200191505060405180910390fd5b806004600082825403925050819055503460096000828254019250508190555080600e60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401600e60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060005b600a811015610b7f57600a339080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506005600081548092919060010191905055508080600101915050610af4565b5050565b600e6020528060005260406000206000915090505481565b60075481565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610c64576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600b8152602001807f4e6f7420416c6c6f77656400000000000000000000000000000000000000000081525060200191505060405180910390fd5b6007544211610cdb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f4c4d4e204c6f74746f206973206e6f742066696e69736865640000000000000081525060200191505060405180910390fd5b6000600d60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205411610d2757600080fd5b6000600d60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050670de0b6b3a7640000810290506000600a6002830281610d8757fe5b0490508082039150600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610df7573d6000803e3d6000fd5b508273ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f19350505050158015610e3e573d6000803e3d6000fd5b506000600d60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505050565b60095481565b600a8181548110610e9c57fe5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610f875780601f10610f5c57610100808354040283529160200191610f87565b820191906000526020600020905b815481529060010190602001808311610f6a57829003601f168201915b505050505081565b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156110255780601f10610ffa57610100808354040283529160200191611025565b820191906000526020600020905b81548152906001019060200180831161100857829003601f168201915b505050505081565b60045481565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60035481565b60075442116110d6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f4c4d4e204c6f74746f206973206e6f742066696e69736865640000000000000081525060200191505060405180910390fd5b6000600d60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541161112257600080fd5b6000600d60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050670de0b6b3a7640000810290506000600a600283028161118257fe5b0490508082039150600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f193505050501580156111f2573d6000803e3d6000fd5b503373ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f19350505050158015611239573d6000803e3d6000fd5b506000600d60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505050565b6000600a80549050905090565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611353576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600b8152602001807f4e6f7420416c6c6f77656400000000000000000000000000000000000000000081525060200191505060405180910390fd5b60006005541161136257600080fd5b600554600143034060001c8161137457fe5b06600681905550600a6006548154811061138a57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600554600d6000600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000600581905550600354600481905550600a60006114df9190611aea565b565b60055481565b60075442111561155f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f4c4d4e204c6f74746f20697320436c6f7365640000000000000000000000000081525060200191505060405180910390fd5b674563918244f40000341461157357600080fd5b6000670de0b6b3a7640000348161158657fe5b04905060035481600554011115611605576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f4e6f206d6f7265204c4d4e204c6f74746f205469636b6574730000000000000081525060200191505060405180910390fd5b806004600082825403925050819055503460096000828254019250508190555080600e60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401600e60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060005b600581101561173857600a339080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060056000815480929190600101919050555080806001019150506116ad565b5050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6007544211156117da576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f4c4d4e204c6f74746f20697320436c6f7365640000000000000000000000000081525060200191505060405180910390fd5b670de0b6b3a764000034146117ee57600080fd5b6000670de0b6b3a7640000348161180157fe5b04905060035481600554011115611880576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f4e6f206d6f7265204c4d4e204c6f74746f205469636b6574730000000000000081525060200191505060405180910390fd5b806004600082825403925050819055503460096000828254019250508190555080600e60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401600e60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600a339080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060056000815480929190600101919050555050565b600d6020528060005260406000206000915090505481565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611a78576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600b8152602001807f4e6f7420416c6c6f77656400000000000000000000000000000000000000000081525060200191505060405180910390fd5b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015611ae0573d6000803e3d6000fd5b5050565b60065481565b5080546000825590600052602060002090810190611b089190611b0b565b50565b5b80821115611b24576000816000905550600101611b0c565b509056fea264697066735822122054cc1a7f90827584d90bf87a4415ac2ad22e73af73551ae9c0f5450d62ca5dba64736f6c634300060c0033