Skip to content

Commit ee6d6ce

Browse files
Merge pull request #6 from monad-developers/fix/contract-verification
Fix/contract verification
2 parents 84979a2 + d6e0b3c commit ee6d6ce

File tree

3 files changed

+65
-3
lines changed

3 files changed

+65
-3
lines changed

packages/hardhat/hardhat.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const config: HardhatUserConfig = {
6464
sourcify: {
6565
enabled: true,
6666
apiUrl: "https://sourcify-api-monad.blockvision.org",
67-
browserUrl: "https://testnet.monadexplorer.com/",
67+
browserUrl: "https://testnet.monadexplorer.com",
6868
},
6969
};
7070

packages/hardhat/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
"lint-staged": "eslint --config ./.eslintrc.json --ignore-path ./.eslintignore",
1515
"format": "prettier --write ./*.ts ./deploy/**/*.ts ./scripts/**/*.ts ./test/**/*.ts",
1616
"test": "REPORT_GAS=true hardhat test --network monadDevnet",
17-
"verify": "hardhat etherscan-verify",
18-
"hardhat-verify": "hardhat verify"
17+
"verify": "hardhat run scripts/verifyContract.ts"
1918
},
2019
"devDependencies": {
2120
"@ethersproject/abi": "^5.7.0",
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import { exec } from "child_process";
2+
import fs from "fs";
3+
import path from "path";
4+
import util from "util";
5+
6+
const execPromise = util.promisify(exec);
7+
8+
async function main() {
9+
try {
10+
// Get the deployments directory path
11+
const deploymentsPath = path.join(__dirname, "../deployments/monadTestnet");
12+
13+
// Read all files in the deployments directory
14+
const files = fs.readdirSync(deploymentsPath);
15+
16+
// Filter for .json files and get the latest one by modification time
17+
const jsonFiles = files
18+
.filter(file => file.endsWith(".json"))
19+
.map(file => ({
20+
name: file,
21+
time: fs.statSync(path.join(deploymentsPath, file)).mtime.getTime(),
22+
}))
23+
.sort((a, b) => b.time - a.time);
24+
25+
if (jsonFiles.length === 0) {
26+
throw new Error("No deployment files found");
27+
}
28+
29+
// Read the latest deployment file
30+
const latestDeployment = JSON.parse(fs.readFileSync(path.join(deploymentsPath, jsonFiles[0].name), "utf8"));
31+
32+
const contractAddress = latestDeployment.address;
33+
const constructorArgs = latestDeployment.args;
34+
35+
console.log(`Latest deployed contract address: ${contractAddress}`);
36+
console.log(`Contract name: ${jsonFiles[0].name.replace(".json", "")}`);
37+
console.log(`Constructor arguments: ${constructorArgs.join(", ")}`);
38+
39+
// Run the verify command with constructor arguments
40+
console.log("Starting verification...");
41+
const { stdout, stderr } = await execPromise(
42+
`yarn hardhat verify --network monadTestnet ${contractAddress} ${constructorArgs.join(" ")}`,
43+
);
44+
45+
console.log("Verification output:");
46+
console.log(stdout);
47+
48+
if (stderr) {
49+
console.error("Verification errors:");
50+
console.error(stderr);
51+
}
52+
} catch (error) {
53+
console.error("Error during verification:", error);
54+
process.exit(1);
55+
}
56+
}
57+
58+
main()
59+
.then(() => process.exit(0))
60+
.catch(error => {
61+
console.error(error);
62+
process.exit(1);
63+
});

0 commit comments

Comments
 (0)