feat: Verify contracts on etherscan

--- don't change below this line ---
ENG-4260 Took 31 minutes
This commit is contained in:
Diana Carvalho
2025-02-27 15:52:32 +00:00
parent 87e7394b0a
commit 79045e2689
6 changed files with 46 additions and 7 deletions

View File

@@ -1,5 +1,6 @@
/** @type import('hardhat/config').HardhatUserConfig */
require("@tenderly/hardhat-tenderly");
require("@nomicfoundation/hardhat-verify");
require("@nomiclabs/hardhat-ethers");
require("@nomicfoundation/hardhat-foundry");
@@ -40,6 +41,10 @@ module.exports = {
tenderly: {
project: "project",
username: "tvinagre",
privateVerification: true,
privateVerification: false,
},
etherscan: {
apiKey: process.env.ETHERSCAN_API_KEY,
}
};

View File

@@ -11,6 +11,7 @@
"prompt-sync": "^4.2.0"
},
"devDependencies": {
"@nomicfoundation/hardhat-verify": "^2.0.13",
"@nomiclabs/hardhat-ethers": "^2.2.3",
"@tenderly/hardhat-tenderly": "^2.5.2",
"dotenv": "^16.4.7",
@@ -1928,9 +1929,9 @@
}
},
"node_modules/@nomicfoundation/hardhat-verify": {
"version": "2.0.12",
"resolved": "https://registry.npmjs.org/@nomicfoundation/hardhat-verify/-/hardhat-verify-2.0.12.tgz",
"integrity": "sha512-Lg3Nu7DCXASQRVI/YysjuAX2z8jwOCbS0w5tz2HalWGSTZThqA0v9N0v0psHbKNqzPJa8bNOeapIVSziyJTnAg==",
"version": "2.0.13",
"resolved": "https://registry.npmjs.org/@nomicfoundation/hardhat-verify/-/hardhat-verify-2.0.13.tgz",
"integrity": "sha512-i57GX1sC0kYGyRVnbQrjjyBTpWTKgrvKC+jH8CMKV6gHp959Upb8lKaZ58WRHIU0espkulTxLnacYeUDirwJ2g==",
"dev": true,
"dependencies": {
"@ethersproject/abi": "^5.1.2",

View File

@@ -1,6 +1,7 @@
{
"name": "hardhat-project",
"devDependencies": {
"@nomicfoundation/hardhat-verify": "^2.0.13",
"@nomiclabs/hardhat-ethers": "^2.2.3",
"@tenderly/hardhat-tenderly": "^2.5.2",
"dotenv": "^16.4.7",

View File

@@ -25,6 +25,7 @@ export PRIVATE_KEY=<private-key>
export RPC_URL=<chain-rpc-url>
export DEPLOY_WALLET=<wallet-address>
export PRIVATE_KEY=<private-key>
export ETHERSCAN_API_KEY=<etherscan-api-key>
```
Make sure to run `unset HISTFILE` in your terminal before setting the private key. This will prevent the private key

View File

@@ -25,15 +25,29 @@ async function main() {
await deployedExecutor.deployed();
console.log(`${exchange} deployed to: ${deployedExecutor.address}`);
// Verify on Tenderly
try {
await hre.tenderly.verify({
name: exchange,
address: deployedExecutor.address,
address: address,
});
console.log("Contract verified successfully on Tenderly");
} catch (error) {
console.error("Error during contract verification:", error);
}
console.log("Waiting for 1 minute before verifying the contract...");
await new Promise(resolve => setTimeout(resolve, 60000));
// Verify on Etherscan
try {
await hre.run("verify:verify", {
address: address,
constructorArguments: args,
});
console.log(`${exchange} verified successfully on Etherscan!`);
} catch (error) {
console.error(`Error during Etherscan verification:`, error);
}
}
}

View File

@@ -20,17 +20,19 @@ async function main() {
console.log(`Deploying TychoRouter to ${network} with:`);
console.log(`- permit2: ${permit2}`);
console.log(`- weth: ${weth}`);
const args = [permit2, weth];
const [deployer] = await ethers.getSigners();
console.log(`Deploying with account: ${deployer.address}`);
console.log(`Account balance: ${ethers.utils.formatEther(await deployer.getBalance())} ETH`);
const TychoRouter = await ethers.getContractFactory("TychoRouter");
const router = await TychoRouter.deploy(permit2, weth);
const router = await TychoRouter.deploy(args);
await router.deployed();
console.log(`TychoRouter deployed to: ${router.address}`);
// Verify on Tenderly
try {
console.log("Verifying contract on Tenderly...");
await hre.tenderly.verify({
@@ -41,6 +43,21 @@ async function main() {
} catch (error) {
console.error("Error during contract verification:", error);
}
console.log("Waiting for 1 minute before verifying the contract...");
await new Promise(resolve => setTimeout(resolve, 60000));
// Verify on Etherscan
try {
await hre.run("verify:verify", {
address: router.address,
constructorArguments: args,
});
console.log(`TychoRouter verified successfully on Etherscan!`);
} catch (error) {
console.error(`Error during Etherscan verification:`, error);
}
}
main()