{"id":19769161,"url":"https://github.com/samsshow/lottery-contract","last_synced_at":"2026-05-11T21:36:30.047Z","repository":{"id":239214765,"uuid":"798795061","full_name":"SamsShow/Lottery-Contract","owner":"SamsShow","description":"Hardhat Smart Contract Lottery System","archived":false,"fork":false,"pushed_at":"2024-05-20T16:12:09.000Z","size":1110,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-11T00:41:53.459Z","etag":null,"topics":["ether","hardhat","web3"],"latest_commit_sha":null,"homepage":"https://sepolia.etherscan.io/address/0xF4EEcB0783BF1BAcc4A559609D12a99F7a6577C3","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SamsShow.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-10T13:42:34.000Z","updated_at":"2024-05-20T16:12:11.000Z","dependencies_parsed_at":"2024-05-20T18:10:47.624Z","dependency_job_id":null,"html_url":"https://github.com/SamsShow/Lottery-Contract","commit_stats":null,"previous_names":["samsshow/lottery-contract"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SamsShow%2FLottery-Contract","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SamsShow%2FLottery-Contract/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SamsShow%2FLottery-Contract/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SamsShow%2FLottery-Contract/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SamsShow","download_url":"https://codeload.github.com/SamsShow/Lottery-Contract/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241100989,"owners_count":19909821,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ether","hardhat","web3"],"created_at":"2024-11-12T04:41:54.351Z","updated_at":"2026-05-11T21:36:25.026Z","avatar_url":"https://github.com/SamsShow.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lottery-Contract\n Hardhat Smart Contract Lottery System\n\n # Key Components\n\n## Chainlink VRF (Verifiable Random Function)\n- Ensures that the random number used to select the winner is provably random and tamper-proof.\n\n## Chainlink Keepers\n- Automates the execution of the contract based on predefined conditions (e.g., time intervals).\n\n# State Variables\n\n## Chainlink VRF Variables\n- `i_vrfCoordinatorV2`: Address of the VRFCoordinatorV2 contract.\n- `i_subscriptionId`: Subscription ID for Chainlink VRF.\n- `i_gasLane`: Maximum gas price for the callback request.\n- `i_callbackGasLimit`: Maximum gas to be used for the callback.\n- `REQUEST_CONFIRMATIONS`: Number of confirmations required before the VRF response is considered.\n- `NUM_WORDS`: Number of random words requested.\n\n## Lottery Variables\n- `i_interval`: Time interval for each raffle draw.\n- `i_entranceFee`: Fee to enter the raffle.\n- `s_lastTimeStamp`: Timestamp of the last raffle draw.\n- `s_recentWinner`: Address of the most recent winner.\n- `s_players`: List of players in the current raffle.\n- `s_raffleState`: State of the raffle (OPEN or CALCULATING).\n\n# Events\n\n- `RequestedRaffleWinner(uint256 indexed requestId)`: Emitted when a random winner is requested.\n- `RaffleEnter(address indexed player)`: Emitted when a player enters the raffle.\n- `WinnerPicked(address indexed player)`: Emitted when a winner is picked.\n\n# Functions\n\n## Constructor\n- Initializes the contract with the necessary parameters and sets the initial state of the raffle to OPEN.\n\n## enterRaffle\n- Allows users to enter the raffle by sending the required entrance fee.\n- Adds the player's address to the `s_players` array.\n- Emits the `RaffleEnter` event.\n\n## checkUpkeep\n- Called by Chainlink Keepers to check if the upkeep (i.e., selecting a winner) is needed.\n- Returns `true` if the time interval has passed, the raffle is open, there are players, and the contract has a balance.\n\n## performUpkeep\n- Called by Chainlink Keepers when `checkUpkeep` returns `true`.\n- Initiates the random number request to Chainlink VRF.\n- Sets the raffle state to CALCULATING.\n- Emits the `RequestedRaffleWinner` event.\n\n## fulfillRandomWords\n- Callback function called by Chainlink VRF with the random number.\n- Uses the random number to select a winner from the `s_players` array.\n- Resets the raffle state to OPEN, clears the players array, updates the last timestamp, and transfers the contract balance to the winner.\n- Emits the `WinnerPicked` event.\n\n# Error Handling\n\n## Custom Errors\n- `Raffle__UpkeepNotNeeded`: Thrown when upkeep is not needed.\n- `Raffle__TransferFailed`: Thrown when the transfer to the winner fails.\n- `Raffle__SendMoreToEnterRaffle`: Thrown when the sent ETH is less than the entrance fee.\n- `Raffle__RaffleNotOpen`: Thrown when the raffle is not open.\n- `Raffle__NotEnoughETHEntered`: Thrown when not enough ETH is sent to enter the raffle.\n\n# Getter Functions\n\n- `getRaffleState`\n- `getNumWords`\n- `getRequestConfirmations`\n- `getRecentWinner`\n- `getPlayer`\n- `getLastTimeStamp`\n- `getInterval`\n- `getEntranceFee`\n- `getNumberOfPlayers`\n\nFunctions to retrieve the state and configuration of the raffle.\n\n# Summary\n\nThis contract ensures a fair and automated raffle system by leveraging Chainlink's VRF for randomness and Keepers for automation. Users can participate by sending ETH, and the contract will automatically select a winner at defined intervals, transferring the accumulated prize to the winner. The use of custom errors and events helps in monitoring and debugging the contract's operation.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamsshow%2Flottery-contract","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamsshow%2Flottery-contract","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamsshow%2Flottery-contract/lists"}