feat: Verify contracts on etherscan
--- don't change below this line --- ENG-4260 Took 31 minutes
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
/** @type import('hardhat/config').HardhatUserConfig */
|
/** @type import('hardhat/config').HardhatUserConfig */
|
||||||
require("@tenderly/hardhat-tenderly");
|
require("@tenderly/hardhat-tenderly");
|
||||||
|
require("@nomicfoundation/hardhat-verify");
|
||||||
require("@nomiclabs/hardhat-ethers");
|
require("@nomiclabs/hardhat-ethers");
|
||||||
require("@nomicfoundation/hardhat-foundry");
|
require("@nomicfoundation/hardhat-foundry");
|
||||||
|
|
||||||
@@ -40,6 +41,10 @@ module.exports = {
|
|||||||
tenderly: {
|
tenderly: {
|
||||||
project: "project",
|
project: "project",
|
||||||
username: "tvinagre",
|
username: "tvinagre",
|
||||||
privateVerification: true,
|
privateVerification: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
etherscan: {
|
||||||
|
apiKey: process.env.ETHERSCAN_API_KEY,
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
7
foundry/package-lock.json
generated
7
foundry/package-lock.json
generated
@@ -11,6 +11,7 @@
|
|||||||
"prompt-sync": "^4.2.0"
|
"prompt-sync": "^4.2.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@nomicfoundation/hardhat-verify": "^2.0.13",
|
||||||
"@nomiclabs/hardhat-ethers": "^2.2.3",
|
"@nomiclabs/hardhat-ethers": "^2.2.3",
|
||||||
"@tenderly/hardhat-tenderly": "^2.5.2",
|
"@tenderly/hardhat-tenderly": "^2.5.2",
|
||||||
"dotenv": "^16.4.7",
|
"dotenv": "^16.4.7",
|
||||||
@@ -1928,9 +1929,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@nomicfoundation/hardhat-verify": {
|
"node_modules/@nomicfoundation/hardhat-verify": {
|
||||||
"version": "2.0.12",
|
"version": "2.0.13",
|
||||||
"resolved": "https://registry.npmjs.org/@nomicfoundation/hardhat-verify/-/hardhat-verify-2.0.12.tgz",
|
"resolved": "https://registry.npmjs.org/@nomicfoundation/hardhat-verify/-/hardhat-verify-2.0.13.tgz",
|
||||||
"integrity": "sha512-Lg3Nu7DCXASQRVI/YysjuAX2z8jwOCbS0w5tz2HalWGSTZThqA0v9N0v0psHbKNqzPJa8bNOeapIVSziyJTnAg==",
|
"integrity": "sha512-i57GX1sC0kYGyRVnbQrjjyBTpWTKgrvKC+jH8CMKV6gHp959Upb8lKaZ58WRHIU0espkulTxLnacYeUDirwJ2g==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ethersproject/abi": "^5.1.2",
|
"@ethersproject/abi": "^5.1.2",
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "hardhat-project",
|
"name": "hardhat-project",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@nomicfoundation/hardhat-verify": "^2.0.13",
|
||||||
"@nomiclabs/hardhat-ethers": "^2.2.3",
|
"@nomiclabs/hardhat-ethers": "^2.2.3",
|
||||||
"@tenderly/hardhat-tenderly": "^2.5.2",
|
"@tenderly/hardhat-tenderly": "^2.5.2",
|
||||||
"dotenv": "^16.4.7",
|
"dotenv": "^16.4.7",
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
## Deploy on a Tenderly fork
|
## Deploy on a Tenderly fork
|
||||||
|
|
||||||
1. Make a new [fork](https://dashboard.tenderly.co/) in tenderly dashboard for the
|
1. Make a new [fork](https://dashboard.tenderly.co/) in tenderly dashboard for the
|
||||||
chain that you wish to deploy on.
|
chain that you wish to deploy on.
|
||||||
2. Set the following environment variables:
|
2. Set the following environment variables:
|
||||||
|
|
||||||
@@ -25,6 +25,7 @@ export PRIVATE_KEY=<private-key>
|
|||||||
export RPC_URL=<chain-rpc-url>
|
export RPC_URL=<chain-rpc-url>
|
||||||
export DEPLOY_WALLET=<wallet-address>
|
export DEPLOY_WALLET=<wallet-address>
|
||||||
export PRIVATE_KEY=<private-key>
|
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
|
Make sure to run `unset HISTFILE` in your terminal before setting the private key. This will prevent the private key
|
||||||
|
|||||||
@@ -25,15 +25,29 @@ async function main() {
|
|||||||
await deployedExecutor.deployed();
|
await deployedExecutor.deployed();
|
||||||
console.log(`${exchange} deployed to: ${deployedExecutor.address}`);
|
console.log(`${exchange} deployed to: ${deployedExecutor.address}`);
|
||||||
|
|
||||||
|
// Verify on Tenderly
|
||||||
try {
|
try {
|
||||||
await hre.tenderly.verify({
|
await hre.tenderly.verify({
|
||||||
name: exchange,
|
name: exchange,
|
||||||
address: deployedExecutor.address,
|
address: address,
|
||||||
});
|
});
|
||||||
console.log("Contract verified successfully on Tenderly");
|
console.log("Contract verified successfully on Tenderly");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error during contract verification:", 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,17 +20,19 @@ async function main() {
|
|||||||
console.log(`Deploying TychoRouter to ${network} with:`);
|
console.log(`Deploying TychoRouter to ${network} with:`);
|
||||||
console.log(`- permit2: ${permit2}`);
|
console.log(`- permit2: ${permit2}`);
|
||||||
console.log(`- weth: ${weth}`);
|
console.log(`- weth: ${weth}`);
|
||||||
|
const args = [permit2, weth];
|
||||||
|
|
||||||
const [deployer] = await ethers.getSigners();
|
const [deployer] = await ethers.getSigners();
|
||||||
console.log(`Deploying with account: ${deployer.address}`);
|
console.log(`Deploying with account: ${deployer.address}`);
|
||||||
console.log(`Account balance: ${ethers.utils.formatEther(await deployer.getBalance())} ETH`);
|
console.log(`Account balance: ${ethers.utils.formatEther(await deployer.getBalance())} ETH`);
|
||||||
|
|
||||||
const TychoRouter = await ethers.getContractFactory("TychoRouter");
|
const TychoRouter = await ethers.getContractFactory("TychoRouter");
|
||||||
const router = await TychoRouter.deploy(permit2, weth);
|
const router = await TychoRouter.deploy(args);
|
||||||
|
|
||||||
await router.deployed();
|
await router.deployed();
|
||||||
console.log(`TychoRouter deployed to: ${router.address}`);
|
console.log(`TychoRouter deployed to: ${router.address}`);
|
||||||
|
|
||||||
|
// Verify on Tenderly
|
||||||
try {
|
try {
|
||||||
console.log("Verifying contract on Tenderly...");
|
console.log("Verifying contract on Tenderly...");
|
||||||
await hre.tenderly.verify({
|
await hre.tenderly.verify({
|
||||||
@@ -41,6 +43,21 @@ async function main() {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error during contract verification:", 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()
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user