feat: Add deployment and fund wallet scripts

--- don't change below this line ---
ENG-4101 Took 1 hour 2 minutes


Took 2 minutes

Took 8 minutes

Took 4 minutes

Took 28 minutes
This commit is contained in:
Diana Carvalho
2025-02-21 18:11:45 +00:00
parent 08f72e7138
commit cbea0bdab3
6 changed files with 6677 additions and 0 deletions

27
foundry/hardhat.config.js Normal file
View File

@@ -0,0 +1,27 @@
/** @type import('hardhat/config').HardhatUserConfig */
require("@nomiclabs/hardhat-ethers");
require("@nomicfoundation/hardhat-foundry");
// require("@tenderly/hardhat-tenderly");
module.exports = {
solidity: {
version: "0.8.26",
settings: {
evmVersion: "cancun",
viaIR: true,
},
},
networks: {
tenderly: {
url: process.env.TENDERLY_RPC_URL,
accounts: [process.env.PRIVATE_KEY]
}
},
tenderly: {
project: "project",
username: "tvinagre",
privateVerification: true,
},
};

6544
foundry/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

12
foundry/package.json Normal file
View File

@@ -0,0 +1,12 @@
{
"name": "hardhat-project",
"devDependencies": {
"@nomiclabs/hardhat-ethers": "^2.2.3",
"dotenv": "^16.4.7",
"hardhat": "^2.22.18"
},
"dependencies": {
"@nomicfoundation/hardhat-foundry": "^1.1.3",
"@tenderly/hardhat-tenderly": "^2.3.0"
}
}

17
foundry/scripts/README.md Normal file
View File

@@ -0,0 +1,17 @@
# How to deploy
- Install dependencies `npm install`
## Deploy on Tenderly fork
1. Make a new [fork](https://dashboard.tenderly.co/) in tenderly dashboard.
2. Set the following environment variables:
```
export TENDERLY_RPC_URL=<fork-rpc-from-tenderly>
export DEPLOY_WALLET=<wallet-address>
export PRIVATE_KEY=<private-key>
```
3. Fund wallet: `npx hardhat run scripts/fund-tenderly-fork.js --network tenderly`
4. Deploy router: `npx hardhat run scripts/deploy-router.js --network tenderly`

View File

@@ -0,0 +1,48 @@
require('dotenv').config();
const {ethers} = require("hardhat");
const hre = require("hardhat");
async function main() {
const network = hre.network.name;
const permit2 = "0x000000000022D473030F116dDEE9F6B43aC78BA3";
const weth = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2";
console.log(`Deploying TychoRouter to ${network} with:`);
console.log(`- permit2: ${permit2}`);
console.log(`- weth: ${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);
await router.deployed();
console.log(`TychoRouter deployed to: ${router.address}`);
// Verify contract on Etherscan/tenderly
console.log("Waiting a bit before verifying...");
// Wait for a few more confirmations before verifying
await new Promise(resolve => setTimeout(resolve, 10000));
// TODO: this doesn't work aarrggghh when I install and add hardhat-tenderly everything dies. I think it's a version mismatch with ethers
// try {
// console.log("Verifying contract on Tenderly...");
// await hre.tenderly.verify({
// name: "TychoRouter",
// address: router.address,
// });
// console.log("Contract verified successfully on Tenderly");
// } catch (error) {
// console.error("Error during contract verification:", error);
// }
}
// Execute deployment
main()
.then(() => process.exit(0))
.catch((error) => {
console.error("Deployment failed:", error);
process.exit(1);
});

View File

@@ -0,0 +1,29 @@
require("dotenv").config();
const {ethers} = require("hardhat");
const TENDERLY_RPC_URL = process.env.TENDERLY_RPC_URL;
const DEPLOY_WALLET = process.env.DEPLOY_WALLET;
async function main() {
if (!TENDERLY_RPC_URL || !DEPLOY_WALLET) {
console.error("Missing TENDERLY_RPC_URL or DEPLOY_WALLET in environment variables.");
process.exit(1);
}
const provider = ethers.provider; // Use Hardhat's provider
const balanceHex = ethers.utils.hexValue(ethers.utils.parseUnits("10", "ether")); // Convert 10 ETH to hex
console.log(`Funding wallet ${DEPLOY_WALLET} with 10 ETH on Tenderly...`);
try {
const result = await provider.send("tenderly_setBalance", [[DEPLOY_WALLET], balanceHex]);
console.log(`Successfully funded wallet: ${DEPLOY_WALLET}`);
console.log(result);
} catch (error) {
console.error("Error funding wallet:", error);
}
}
main().catch((error) => {
console.error(error);
process.exit(1);
});