8. Contract Lottery | Raffle

One Liner Dependencies Installation

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


Last updated