-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathhardhat.config.cts
76 lines (68 loc) · 2.25 KB
/
hardhat.config.cts
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
import '@nomicfoundation/hardhat-toolbox-viem';
import '@nomicfoundation/hardhat-viem';
import '@nomicfoundation/hardhat-chai-matchers';
import 'hardhat-noirenberg';
import { writeFileSync } from 'fs';
import { Chain } from 'viem';
import { task, vars } from 'hardhat/config';
import { HardhatUserConfig } from 'hardhat/types/config';
import fs from 'fs';
import { resolve } from 'path';
const config: HardhatUserConfig = {
solidity: {
version: '0.8.28',
settings: {
optimizer: { enabled: true, runs: 5000 },
},
},
defaultNetwork: 'localhost',
networks: {
localhost: {
url: 'http://127.0.0.1:8545',
chainId: 31337,
accounts: vars.has('localhost')
? [vars.get('localhost')]
: ['0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80'],
},
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: 'packages',
tests: 'tests',
},
};
task('deploy', 'Deploys a verifier contract')
.addOptionalPositionalParam('provingSystem')
.setAction(async (taskArgs, hre) => {
const contractsDir = resolve('packages', 'contracts');
if (fs.existsSync(contractsDir)) fs.rmdirSync(contractsDir, { recursive: true });
hre.config.noirenberg = { provingSystem: taskArgs.provingSystem || 'UltraPlonk' };
await hre.run('compile');
let verifier;
if (taskArgs.provingSystem === 'UltraHonk') {
verifier = await hre.viem.deployContract('HonkVerifier');
} else {
verifier = await hre.viem.deployContract('UltraVerifier');
}
const networkConfig = (await import(`viem/chains`))[hre.network.name] as Chain;
const config = {
name: hre.network.name,
address: verifier.address,
networkConfig: {
...networkConfig,
id: hre.network.config.chainId,
},
};
console.log(
`Attached to address ${verifier.address} at network ${hre.network.name} with chainId ${networkConfig.id}...`,
);
writeFileSync('deployment.json', JSON.stringify(config), { flag: 'w' });
});
export default config;