-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path04-verify.js
More file actions
executable file
·69 lines (58 loc) · 2.3 KB
/
04-verify.js
File metadata and controls
executable file
·69 lines (58 loc) · 2.3 KB
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
#!/usr/bin/env node
import node_fs from 'node:fs/promises';
import dotenv from 'dotenv';
import FILE_PATHS from './util/file-paths.js';
import { Logger } from './util/logger.js';
const processEnv = {};
dotenv.config({
processEnv,
quiet: true,
});
const logger = new Logger();
await logger.init();
async function step04Verify() {
await logger.logScriptBegin('verify');
await logger.logSection('Load deployment data');
const counterDeploymentJsonStr =
await node_fs.readFile(FILE_PATHS.counterDeploymentJson);
const counterDeploymentJson = JSON.parse(counterDeploymentJsonStr);
console.log(counterDeploymentJson);
await logger.logSection('Verify smart contract', logger.f.italic('npx hardhat verify --network inj_testnet ${SC_ADDRESS}'));
await logger.loggerJumpToFileLine(FILE_PATHS.counterSol);
const scAddress = counterDeploymentJson.deployedAddress;
const command = `npx hardhat verify --force --network inj_testnet ${scAddress}`;
await logger.logProcess(command);
const explorerUrl = `https://testnet.blockscout.injective.network/address/${scAddress}?tab=contract_source_code`;
const explorerUrlAnsi = logger.f.url(explorerUrl);
await logger.log('Verify successful!', explorerUrlAnsi);
await logger.logInfoBox(
'What have we accomplished?',
`
1. Connect to Injective Testnet Blockscout
- Using EtherScan API, via hardhat
2. Perform a forced verification
- Forced is needed in case other smart contracts are already deployed at a different address with the same EVM bytecode
3. Inspect the result of the verification
- Open the block explorer URL, to view its source code and ABI
`,
);
}
process.once('SIGINT', async () => {
await logger.logError('verify', 'sigint');
});
process.once('SIGTERM', async () => {
await logger.logError('verify', 'sigterm');
});
step04Verify().then(async () => {
await logger.logScriptEnd('verify');
console.log('To continue, run the following command for the next step:\n', logger.f.bold('./05-interact.js'));
}).catch(async (err) => {
if (err.stdout || err.stderr) {
await logger.logError('verify', err.message);
console.log(err.stdout);
console.log(err.stderr);
} else {
await logger.logError('verify', err.message);
console.log(err);
}
});