-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhardhat.config.js
36 lines (30 loc) · 1.11 KB
/
hardhat.config.js
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
require('dotenv').config();
require("@nomiclabs/hardhat-waffle");
const { task } = require("hardhat/config");
const { PRIVATE_KEY, ROPSTEN_API_URL } = process.env;
task("buyTicket", "buy a Codemotion ticket")
.addParam("contractAddress", "address of the contract")
.setAction(async (args, hre) => {
const contract = await hre.ethers.getContractAt("CodemotionTickets", args.contractAddress);
const txn = await contract.buyTicket(1, { value: hre.ethers.utils.parseEther("0.5") });
const txnResponse = await txn.wait();
console.log("Ticket purchased in transaction " + txnResponse.transactionHash + " (block " + txnResponse.blockNumber + ")");
const verified = await contract.verifyTicket();
if (verified) {
console.log("Awesome! You can access Codemotion conference!");
} else {
console.log("Sorry, you can't access Codemotion conference! Please purchase a ticket!");
}
});
/**
* @type import('hardhat/config').HardhatUserConfig
*/
module.exports = {
networks: {
ropsten: {
url: ROPSTEN_API_URL,
accounts: [ PRIVATE_KEY ],
},
},
solidity: "0.8.4",
};