# 8. Contract Lottery | Raffle

### One Liner Dependencies Installation

```sh
yarn add --dev @nomiclabs/hardhat-ethers@npm:hardhat-deploy-ethers ethers @nomiclabs/hardhat-etherscan @nomiclabs/hardhat-waffle chai ethereum-waffle hardhat hardhat-contract-sizer hardhat-deploy hardhat-gas-reporter prettier prettier-plugin-solidity solhint solidity-coverage dotenv
```

***

### Contract Details

* Raffle
* Enter the lottery (paying some amount)
* Pick a random winner (verifiably random)
* Winner to be selected every X minutes -> completely automate
* Chainlink Oracle -> Randomness, Automated Execution (Chainlink Keepers)

***

### Events

* Whenever we update a dynamic array or mapping, we should emit an event
* Stored in the logging data structure of the EVM
* Whenever we emit an event, there are two types of parameters
  * **indexed** parameters / **topics**
    * We can have upto **3** of these
    * These are seachable
  * **unindexed** parameters
    * Decoded via their ABIs
    * Costs less gas

***

### Hardhat Shorthand

* Npm package that is installed globally as package `hh`
* Supports shell autocomplete
* `yarn global add shorthand`

***

### Hardhat special testing/debugging methods

<https://hardhat.org/hardhat-network/docs/reference#special-testing/debugging-methods>

#### `evm_increaseTime`

Allows us to increase time of the blockchain

#### `evm_mine`

Allows us to mine(create) new blocks

***

### Final Files

<https://github.com/PatrickAlphaC/hardhat-smartcontract-lottery-fcc>

***


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://notes.nomanaziz.me/development/blockchain/freecodecamp-course/8.-contract-lottery-or-raffle.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
