-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhardhat.config.js
55 lines (44 loc) · 1.52 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
require("dotenv").config();
/**
* @type import('hardhat/config').HardhatUserConfig
*/
require("@nomiclabs/hardhat-ethers");
const { API_URL, PRIVATE_KEY, CONTRACT_ADDRESS, CONTRACT_NAME } = process.env;
task("getGreetings", "Prints an account's greeting")
.addParam("account", "The account's address")
.setAction(async (taskArgs) => {
const MyContract = await ethers.getContractFactory(CONTRACT_NAME);
const contract = await MyContract.attach(
CONTRACT_ADDRESS // The deployed contract address
);
// Now you can call functions of the contract
const greetings = await contract.greetings;
console.log("Greeting: ", await greetings(taskArgs.account));
});
task("sayHelloTo", "Say hello to someone")
.addParam("someone", "Someone to greeting")
.setAction(async (taskArgs) => {
const MyContract = await ethers.getContractFactory(CONTRACT_NAME);
const contract = await MyContract.attach(
CONTRACT_ADDRESS // The deployed contract address
);
// Now you can call functions of the contract
const sayHelloToTransaction = await contract.sayHelloTo(taskArgs.someone);
await sayHelloToTransaction.wait();
const greetings = await contract.greetings;
console.log("Greeting: ", await greetings(sayHelloToTransaction.from));
});
module.exports = {
solidity: "0.8.0",
defaultNetwork: "rinkeby",
networks: {
hardhat: {},
localhost: {},
rinkeby: {
url: API_URL,
accounts: [`0x${PRIVATE_KEY}`],
network_id: 4,
gas: 10000000,
},
},
};