-
Notifications
You must be signed in to change notification settings - Fork 0
/
hardhat.config.ts
54 lines (44 loc) · 1.84 KB
/
hardhat.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import {HardhatUserConfig, task} from "hardhat/config"
import {defaultNetwork, entryCost, networks, txGasLimit} from "./src/config"
import {DRaffle} from "./typechain-types"
import "@nomicfoundation/hardhat-toolbox"
import "hardhat-deploy"
import "hardhat-deploy-ethers"
const config: HardhatUserConfig = {
solidity: "0.8.18",
defaultNetwork,
networks: networks,
};
// hardhat hates you adding imports, because it just pulls in the code for the task manually (ew)
// so although this 'isn't typechecked', it is really
task(
"draw",
"draws winners of the drand raffle for the current block",
)
.addParam("contract", "The address of the draffle contract")
.setAction(async (taskArgs) => {
const contractAddr = taskArgs.contract
const account = network.config.accounts[0]
const wallet = new ethers.Wallet(account, ethers.provider)
const dRaffle = await ethers.getContractFactory("DRaffle", wallet)
const dRaffleContract = await dRaffle.attach(contractAddr)
const tx = await dRaffleContract.draw({gasLimit: txGasLimit})
try {
await tx.wait(1)
console.log("draw triggered!")
} catch (err) {
console.error("it was too early to trigger the draw")
}
})
task("enter-draw", "enter the draw for a given address")
.addParam("contract", "The address of the draffle contract")
.setAction(async (taskArgs) => {
const contractAddr = taskArgs.contract
const account = network.config.accounts[0]
const wallet = new ethers.Wallet(account, ethers.provider)
const dRaffle = await ethers.getContractFactory("DRaffle", wallet)
const dRaffleContract = await dRaffle.attach(contractAddr)
const tx = await dRaffleContract.enter({value: entryCost})
await tx.wait(1)
})
export default config;