Feature Tip: Add private address tag to any address under My Name Tag !
Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 9 from a total of 9 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Pick Winner | 20115892 | 308 days ago | IN | 0 ETH | 0.00049697 | ||||
Transfer | 19997719 | 324 days ago | IN | 0.001 ETH | 0.00027397 | ||||
Transfer | 19997680 | 324 days ago | IN | 0.001 ETH | 0.00086359 | ||||
Pick Winner | 19995513 | 324 days ago | IN | 0 ETH | 0.00035523 | ||||
Transfer | 19995495 | 324 days ago | IN | 0.001 ETH | 0.00019238 | ||||
Transfer | 19995475 | 324 days ago | IN | 0.001 ETH | 0.00016738 | ||||
Transfer | 19995387 | 324 days ago | IN | 0.001 ETH | 0.00016773 | ||||
Transfer | 19995358 | 324 days ago | IN | 0.001 ETH | 0.00017769 | ||||
Transfer | 19995268 | 325 days ago | IN | 0.001 ETH | 0.00055258 |
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
ExperienceLottery
Compiler Version
v0.8.26+commit.8a97fa7a
Optimization Enabled:
Yes with 1000 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.26; /// @author: @quentinmerabet import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; contract ExperienceLottery is Ownable(msg.sender), ReentrancyGuard { uint public constant DEV_PERCENT = 5; uint public constant MIN_ENTRY_PRICE = 0.001 ether; mapping(uint round => mapping(address player => uint amount)) public roundToPlayerToAmount; address[] public currentPlayers; uint public currentRound; uint public totalAmount; event PlayerEntered(address indexed player, uint amount, uint round); event PlayerWon(address indexed player, uint amount, uint round); constructor() {} receive() external payable { require( msg.value >= MIN_ENTRY_PRICE, "You need to send more than the minimum entry price" ); bool isNewPlayer = roundToPlayerToAmount[currentRound][msg.sender] == 0; if (isNewPlayer) { currentPlayers.push(msg.sender); } roundToPlayerToAmount[currentRound][msg.sender] += msg.value; totalAmount += msg.value; emit PlayerEntered(msg.sender, msg.value, currentRound); } function pickWinner() external onlyOwner nonReentrant { require(currentPlayers.length > 0, "No players yet"); uint randomValue = random() % totalAmount; uint cumulativeSum = 0; address winner; for (uint i = 0; i < currentPlayers.length; i++) { address player = currentPlayers[i]; cumulativeSum += roundToPlayerToAmount[currentRound][player]; if (cumulativeSum > randomValue) { winner = player; break; } } uint devFee = (totalAmount * DEV_PERCENT) / 100; uint winnerAmount = totalAmount - devFee; (bool successOwner, ) = owner().call{value: devFee}(""); require(successOwner, "Transfer to owner failed"); (bool successWinner, ) = winner.call{value: winnerAmount}(""); require(successWinner, "Transfer to winner failed"); // Reset the lottery state totalAmount = 0; delete currentPlayers; ++currentRound; emit PlayerWon(winner, winnerAmount, currentRound); } function random() private view returns (uint) { return uint( keccak256( abi.encodePacked( block.prevrandao, block.timestamp, currentPlayers ) ) ); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol) pragma solidity ^0.8.20; import {Context} from "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * The initial owner is set to the address provided by the deployer. This can * later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; /** * @dev The caller account is not authorized to perform an operation. */ error OwnableUnauthorizedAccount(address account); /** * @dev The owner is not a valid owner account. (eg. `address(0)`) */ error OwnableInvalidOwner(address owner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the address provided by the deployer as the initial owner. */ constructor(address initialOwner) { if (initialOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(initialOwner); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { if (owner() != _msgSender()) { revert OwnableUnauthorizedAccount(_msgSender()); } } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { if (newOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol) pragma solidity ^0.8.20; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol) pragma solidity ^0.8.20; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant NOT_ENTERED = 1; uint256 private constant ENTERED = 2; uint256 private _status; /** * @dev Unauthorized reentrant call. */ error ReentrancyGuardReentrantCall(); constructor() { _status = NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { // On the first call to nonReentrant, _status will be NOT_ENTERED if (_status == ENTERED) { revert ReentrancyGuardReentrantCall(); } // Any calls to nonReentrant after this point will fail _status = ENTERED; } function _nonReentrantAfter() private { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = NOT_ENTERED; } /** * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a * `nonReentrant` function in the call stack. */ function _reentrancyGuardEntered() internal view returns (bool) { return _status == ENTERED; } }
{ "viaIR": true, "optimizer": { "enabled": true, "runs": 1000 }, "evmVersion": "paris", "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"player","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"round","type":"uint256"}],"name":"PlayerEntered","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"player","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"round","type":"uint256"}],"name":"PlayerWon","type":"event"},{"inputs":[],"name":"DEV_PERCENT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_ENTRY_PRICE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"currentPlayers","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"currentRound","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pickWinner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"round","type":"uint256"},{"internalType":"address","name":"player","type":"address"}],"name":"roundToPlayerToAmount","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
60808060405234607957331560635760008054336001600160a01b0319821681178355916001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09080a3600180556108f1908161007f8239f35b631e4fbdf760e01b600052600060045260246000fd5b600080fdfe608080604052600436101561018f575b50361561001b57600080fd5b66038d7ea4c68000341061012557600454600052600260205260406000206001600160a01b033316600052602052604060002054156100cd575b600454600052600260205260406000206001600160a01b033316600052602052604060002061008534825461080a565b90556100933460055461080a565b6005556004546040519034825260208201527f480a6daea81f2af589e1959da1f1719512392ec551e8966266ee820f1c1f72ea60403392a2005b6003546801000000000000000081101561010f578060016100f192016003556107d9565b81549060031b906001600160a01b0333831b921b1916179055610055565b634e487b7160e01b600052604160045260246000fd5b608460405162461bcd60e51b815260206004820152603260248201527f596f75206e65656420746f2073656e64206d6f7265207468616e20746865206d60448201527f696e696d756d20656e74727920707269636500000000000000000000000000006064820152fd5b60003560e01c9081631a39d8ef146107be575080631f5b7cdf1461076a57806327532d271461074e5780635d495aea146103cf578063703afc871461038e578063715018a6146103285780638a19c8bc1461030a5780638da5cb5b146102e3578063d7c7eaf2146102c15763f2fde38b1461020a573861000f565b346102bc5760203660031901126102bc576004356001600160a01b0381168091036102bc57610237610879565b801561028d576001600160a01b036000548273ffffffffffffffffffffffffffffffffffffffff19821617600055167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3005b7f1e4fbdf700000000000000000000000000000000000000000000000000000000600052600060045260246000fd5b600080fd5b346102bc5760003660031901126102bc57602060405166038d7ea4c680008152f35b346102bc5760003660031901126102bc5760206001600160a01b0360005416604051908152f35b346102bc5760003660031901126102bc576020600454604051908152f35b346102bc5760003660031901126102bc57610341610879565b60006001600160a01b03815473ffffffffffffffffffffffffffffffffffffffff1981168355167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a3005b346102bc5760203660031901126102bc576004356003548110156102bc576001600160a01b036103bf6020926107d9565b90549060031b1c16604051908152f35b346102bc5760003660031901126102bc576103e8610879565b60026001541461072457600260015560035480156106e0576040516020810190448252426040820152606081016003600052817fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b9160005b8681106106bd575061045b925003601f198101835282610817565b519020906005549182156106a7576004546000929184900683805b84811061063f575b50505050506005820282810460050361053f576064900480830392831161053f576000808080936001600160a01b038254165af16104ba610839565b50156105fb57600080808085855af16104d1610839565b50156105b7576000600555600354600060035580610555575b5060045490600019821461053f576001600160a01b0360409160017faebbe3d3846c4aefb8c05b638e2f00a16b7c1ecbfcd855ef050d2ac61b2f9d27940180600455835195865260208601521692a260018055005b634e487b7160e01b600052601160045260246000fd5b60036000527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b017fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b5b8181106105ab57506104ea565b6000815560010161059e565b606460405162461bcd60e51b815260206004820152601960248201527f5472616e7366657220746f2077696e6e6572206661696c6564000000000000006044820152fd5b606460405162461bcd60e51b815260206004820152601860248201527f5472616e7366657220746f206f776e6572206661696c656400000000000000006044820152fd5b6106856001600160a01b03610653836107d9565b90549060031b1c16928560005260026020526040806000206000906001600160a01b038716825260205220549061080a565b918383116106965750600101610476565b95505050505050828080808061047e565b634e487b7160e01b600052601260045260246000fd5b91506001602081926001600160a01b038654168152019301910191839192610440565b606460405162461bcd60e51b815260206004820152600e60248201527f4e6f20706c6179657273207965740000000000000000000000000000000000006044820152fd5b7f3ee5aeb50000000000000000000000000000000000000000000000000000000060005260046000fd5b346102bc5760003660031901126102bc57602060405160058152f35b346102bc5760403660031901126102bc576024356001600160a01b03811681036102bc5760043560005260026020526001600160a01b03604060002091166000526020526020604060002054604051908152f35b346102bc5760003660031901126102bc576020906005548152f35b6003548110156107f457600360005260206000200190600090565b634e487b7160e01b600052603260045260246000fd5b9190820180921161053f57565b90601f8019910116810190811067ffffffffffffffff82111761010f57604052565b3d15610874573d9067ffffffffffffffff821161010f5760405191610868601f8201601f191660200184610817565b82523d6000602084013e565b606090565b6001600160a01b0360005416330361088d57565b7f118cdaa7000000000000000000000000000000000000000000000000000000006000523360045260246000fdfea26469706673582212202bfc3c602e3d89fa76465c8a9aef69f61e2fd5e7cdb6e7ed3488a03878c13baa64736f6c634300081a0033
Deployed Bytecode
0x608080604052600436101561018f575b50361561001b57600080fd5b66038d7ea4c68000341061012557600454600052600260205260406000206001600160a01b033316600052602052604060002054156100cd575b600454600052600260205260406000206001600160a01b033316600052602052604060002061008534825461080a565b90556100933460055461080a565b6005556004546040519034825260208201527f480a6daea81f2af589e1959da1f1719512392ec551e8966266ee820f1c1f72ea60403392a2005b6003546801000000000000000081101561010f578060016100f192016003556107d9565b81549060031b906001600160a01b0333831b921b1916179055610055565b634e487b7160e01b600052604160045260246000fd5b608460405162461bcd60e51b815260206004820152603260248201527f596f75206e65656420746f2073656e64206d6f7265207468616e20746865206d60448201527f696e696d756d20656e74727920707269636500000000000000000000000000006064820152fd5b60003560e01c9081631a39d8ef146107be575080631f5b7cdf1461076a57806327532d271461074e5780635d495aea146103cf578063703afc871461038e578063715018a6146103285780638a19c8bc1461030a5780638da5cb5b146102e3578063d7c7eaf2146102c15763f2fde38b1461020a573861000f565b346102bc5760203660031901126102bc576004356001600160a01b0381168091036102bc57610237610879565b801561028d576001600160a01b036000548273ffffffffffffffffffffffffffffffffffffffff19821617600055167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3005b7f1e4fbdf700000000000000000000000000000000000000000000000000000000600052600060045260246000fd5b600080fd5b346102bc5760003660031901126102bc57602060405166038d7ea4c680008152f35b346102bc5760003660031901126102bc5760206001600160a01b0360005416604051908152f35b346102bc5760003660031901126102bc576020600454604051908152f35b346102bc5760003660031901126102bc57610341610879565b60006001600160a01b03815473ffffffffffffffffffffffffffffffffffffffff1981168355167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a3005b346102bc5760203660031901126102bc576004356003548110156102bc576001600160a01b036103bf6020926107d9565b90549060031b1c16604051908152f35b346102bc5760003660031901126102bc576103e8610879565b60026001541461072457600260015560035480156106e0576040516020810190448252426040820152606081016003600052817fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b9160005b8681106106bd575061045b925003601f198101835282610817565b519020906005549182156106a7576004546000929184900683805b84811061063f575b50505050506005820282810460050361053f576064900480830392831161053f576000808080936001600160a01b038254165af16104ba610839565b50156105fb57600080808085855af16104d1610839565b50156105b7576000600555600354600060035580610555575b5060045490600019821461053f576001600160a01b0360409160017faebbe3d3846c4aefb8c05b638e2f00a16b7c1ecbfcd855ef050d2ac61b2f9d27940180600455835195865260208601521692a260018055005b634e487b7160e01b600052601160045260246000fd5b60036000527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b017fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b5b8181106105ab57506104ea565b6000815560010161059e565b606460405162461bcd60e51b815260206004820152601960248201527f5472616e7366657220746f2077696e6e6572206661696c6564000000000000006044820152fd5b606460405162461bcd60e51b815260206004820152601860248201527f5472616e7366657220746f206f776e6572206661696c656400000000000000006044820152fd5b6106856001600160a01b03610653836107d9565b90549060031b1c16928560005260026020526040806000206000906001600160a01b038716825260205220549061080a565b918383116106965750600101610476565b95505050505050828080808061047e565b634e487b7160e01b600052601260045260246000fd5b91506001602081926001600160a01b038654168152019301910191839192610440565b606460405162461bcd60e51b815260206004820152600e60248201527f4e6f20706c6179657273207965740000000000000000000000000000000000006044820152fd5b7f3ee5aeb50000000000000000000000000000000000000000000000000000000060005260046000fd5b346102bc5760003660031901126102bc57602060405160058152f35b346102bc5760403660031901126102bc576024356001600160a01b03811681036102bc5760043560005260026020526001600160a01b03604060002091166000526020526020604060002054604051908152f35b346102bc5760003660031901126102bc576020906005548152f35b6003548110156107f457600360005260206000200190600090565b634e487b7160e01b600052603260045260246000fd5b9190820180921161053f57565b90601f8019910116810190811067ffffffffffffffff82111761010f57604052565b3d15610874573d9067ffffffffffffffff821161010f5760405191610868601f8201601f191660200184610817565b82523d6000602084013e565b606090565b6001600160a01b0360005416330361088d57565b7f118cdaa7000000000000000000000000000000000000000000000000000000006000523360045260246000fdfea26469706673582212202bfc3c602e3d89fa76465c8a9aef69f61e2fd5e7cdb6e7ed3488a03878c13baa64736f6c634300081a0033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 34 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.