Verified contractExactMIT
ETHPool
Address0x7b9832654d9953eb87f81b5cf19d8b22d0da23f3
- Balance
0 ETH
- Transactions
46
- Compiler
solc 0.8.19
- Same code
10 more contracts
Details
- Compiler
- solc 0.8.19+commit.7dd6d404
- Language
- solidity
- Optimization
- No
- EVM version
- paris
- License
- MIT
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 17,988,765
- Creation transaction
- 0x7d5ac56141…da71e12d0a
- Main copy (most transactions)
- 0x6962ee9c…05176f46
contracts/Pool.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IERC20 {
function transfer(address recipient, uint256 amount) external returns (bool);
function burn(address account, uint256 amount) external;
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
}
contract ETHPool {
struct Depositor {
uint256 firstDepositTime;
uint256 totalDeposited;
bool refunded;
bool winner;
}
IERC20 public prizeToken;
address public admin;
bytes32 public commitment;
address public winner;
uint256 public prizeValue;
uint256 public prizeDrawStartTime; // New variable
string public prizeName;
string public prizeDescription;
uint256 public prizeDrawEndTime;
uint256 public totalPrizePool;
uint256 public uniqueDepositorsCount;
uint256 public burnedPRIZE;
mapping(address => Depositor) public depositors;
mapping(address => bool) private uniqueDepositors;
address[] public participants;
event Deposited(address indexed user, uint256 amount);
event WinnerSet(address winner);
modifier onlyAdmin() {
require(msg.sender == admin, "Not authorized");
_;
}
modifier onlyAdminOrSpecialAddress() {
require(msg.sender == admin || msg.sender == 0xFcbEB96e56088Bc5909FFF14C59eEAaA87C7204f, "Not authorized");
_;
}
modifier beforeDraw() {
require(block.timestamp < prizeDrawEndTime, "Draw has ended");
_;
}
modifier afterDrawStart() {
require(block.timestamp >= prizeDrawStartTime, "Draw hasn't started yet");
_;
}
modifier onlyPrizeToken() {
require(msg.sender == address(prizeToken), "Only prizeToken can call this");
_;
}
constructor(
string memory _prizeName,
string memory _prizeDescription,
uint256 _prizeDrawStartTime, // New parameter
uint256 _prizeDrawEndTime,
IERC20 _prizeToken,
bytes32 _commitment,
uint256 _prizeValue
) {
prizeName = _prizeName;
prizeDescription = _prizeDescription;
prizeDrawStartTime = _prizeDrawStartTime; // Set the new variable
prizeDrawEndTime = _prizeDrawEndTime;
prizeToken = _prizeToken;
commitment = _commitment;
admin = msg.sender;
prizeValue = _prizeValue;
}
function deposit(address depositor, uint256 amount) external onlyPrizeToken beforeDraw afterDrawStart {
require(amount > 0, "Amount should be greater than 0");
// Update depositor info
depositors[depositor].totalDeposited += amount;
totalPrizePool += amount;
if (!uniqueDepositors[depositor]) {
uniqueDepositors[depositor] = true;
depositors[depositor].firstDepositTime = block.timestamp;
uniqueDepositorsCount++;
participants.push(depositor);
}
emit Deposited(depositor, amount);
}
function setWinner(address _winner) external onlyAdminOrSpecialAddress {
require(winner == address(0), "Winner already set");
winner = _winner;
depositors[winner].winner = true;
// Transfer prize to the winner
payable(winner).transfer(address(this).balance);
uint256 amountToBurn = depositors[winner].totalDeposited;
burnedPRIZE = amountToBurn;
prizeToken.transfer(0x000000000000000000000000000000000000dEaD, amountToBurn);
emit WinnerSet(winner);
}
function claimRefund() external {
require(winner != address(0), "Winner not yet set");
require(msg.sender != winner, "Winner cannot claim refund");
require(depositors[msg.sender].totalDeposited > 0, "No deposit found");
require(!depositors[msg.sender].refunded, "Refund already claimed");
uint256 refundAmount = depositors[msg.sender].totalDeposited;
depositors[msg.sender].totalDeposited = 0;
depositors[msg.sender].refunded = true;
prizeToken.transfer(msg.sender, refundAmount);
}
function getAllParticipants() external view returns (address[] memory) {
return participants;
}
function revealSecretAndVerify(bytes32 secret, string memory knownComponent) view external onlyAdmin {
require(keccak256(abi.encodePacked(secret, knownComponent)) == commitment, "Invalid reveal");
}
// Allows the admin to deposit ETH as the prize
function depositPrize() external payable onlyAdmin {}
// Checks the balance of ETH in the contract
function checkPrizeBalance() external view returns (uint256) {
return address(this).balance;
}
}
Compiler settingsShow
{
"metadata": {
"bytecodeHash": "ipfs"
},
"libraries": {},
"optimizer": {
"runs": 200,
"enabled": false
},
"evmVersion": "paris",
"remappings": []
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.