Lesson 9 from the Web3, Full Stack Solidity, Smart Contract & Blockchain - Beginner to Expert ULTIMATE Course | Javascript Edition: https://github.com/smartcontractkit/full-blockchain-solidity-course-js#lesson-9-hardhat-smart-contract-lottery
Official code at: https://github.com/PatrickAlphaC/hardhat-smartcontract-lottery-fcc
- using the
Automation*
interfaces provided by Chainlink as opposed toKeepers*
(which seems legacy) - in order to register a new
Upkeep
for the sample Remix app using a Custom trigger - replaced
(and similar) with
vrfCoordinatorV2Mock = await ethers.getContract("VRFCoordinatorV2Mock", deployer)
const vrfCoordinatorV2MockDeployment = await deployments.get("VRFCoordinatorV2Mock") vrfCoordinatorV2Mock = await ethers.getContractAt( vrfCoordinatorV2MockDeployment.abi, vrfCoordinatorV2MockDeployment.address )
- replaced
transactionReceipt.events
withtransactionReceipt.logs
- replaced
(and similar) with
await expect(raffle.enterRaffle()).to.be.revertedWith("Raffle__NotEnoughETHEntered")
await expect(raffle.enterRaffle()).to.be.revertedWithCustomError(raffle, "Raffle__NotEnoughETHEntered")
- replaced
interval.toNumber()
withNumber(interval)
- replace
vrfCoordinatorV2Mock.address
withvrfCoordinatorV2Mock.getAddress()
- but not for the freshly deployed
raffle
- but not for the freshly deployed
- using "@chainlink/contracts" version 0.8 instead of 0.4
- the raffle contract must be added to the mock coordinator, otherwise requests will be rejected with reverted with custom error 'InvalidConsumer()':
if (developmentChains.includes(network.name)) { // add the raffle as a consumer await vrfCoordinatorV2Mock.addConsumer(subscriptionId, raffle.address) }
- for
performUpkeep
use"0x"
as argument instead of[]
(this could be an ethers v6 thing)
- the raffle contract must be added to the mock coordinator, otherwise requests will be rejected with reverted with custom error 'InvalidConsumer()':
- for static calls replace
raffle.callStatic.checkUpkeep([])
withraffle.checkUpkeep.staticCall("0x")
(and similar) - replace
accounts[winnerIndex].getBalance()
withethers.provider.getBalance(accounts[winnerIndex].address)