-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhardhat.config.cjs
80 lines (72 loc) · 2.21 KB
/
hardhat.config.cjs
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
require('@nomicfoundation/hardhat-toolbox-viem');
require('@nomicfoundation/hardhat-viem');
require('@nomicfoundation/hardhat-chai-matchers');
const { task } = require('hardhat/config');
const { subtask, vars } = require('hardhat/config');
const { TASK_COMPILE_SOLIDITY } = require('hardhat/builtin-tasks/task-names');
const { join } = require('path');
const { writeFile } = require('fs/promises');
const { mkdirSync, writeFileSync } = require('fs');
subtask(TASK_COMPILE_SOLIDITY).setAction(async (_, { config }, runSuper) => {
const superRes = await runSuper();
try {
await writeFile(join(config.paths.root, 'artifacts', 'package.json'), '{ "type": "commonjs" }');
} catch (error) {
console.error('Error writing package.json: ', error);
}
return superRes;
});
task('node', 'Runs a local blockchain').setAction(async (_, hre, runSuper) => {
console.log("Starting network...")
const networkConfig = (await import(`viem/chains`))[hre.network.name];
const config = {
name: hre.network.name,
networkConfig: {
...networkConfig,
id: hre.network.config.chainId || networkConfig.id,
},
};
mkdirSync('artifacts', { recursive: true });
writeFileSync('artifacts/deployment.json', JSON.stringify(config), { flag: 'w' });
await runSuper();
await hre.network.provider.send("hardhat_reset")
})
module.exports = {
solidity: {
compilers: [
{
version: '0.8.4',
settings: {
optimizer: { enabled: true, runs: 200 },
},
},
],
},
defaultNetwork: 'localhost',
networks: {
localhost: {
url: 'http://127.0.0.1:8545',
chainId: 31337,
accounts: vars.has('localhost')
? [vars.get('localhost')]
: ['0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80'],
mining: {
auto: false,
interval: 5000
}
},
scrollSepolia: {
url: 'https://sepolia-rpc.scroll.io',
accounts: vars.has('scrollSepolia') ? [vars.get('scrollSepolia')] : [],
},
holesky: {
url: 'https://holesky.drpc.org',
accounts: vars.has('holesky') ? [vars.get('holesky')] : [],
},
},
paths: {
root: './',
sources: './artifacts',
artifacts: './artifacts/hardhat',
},
};