Skip to content

Commit

Permalink
Output addresses to json
Browse files Browse the repository at this point in the history
  • Loading branch information
Karan committed Apr 19, 2022
1 parent 974f447 commit dd0029d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ build
coverage.json
yarn-error.log
.env
output.json

#Hardhat files
artifacts
Expand Down
27 changes: 22 additions & 5 deletions scripts/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,41 @@
import { ethers } from "hardhat";
const hre = require("hardhat");
const fs = require('fs')

async function main() {

const output = {
walletImplementation: "",
walletFactory: "",
forwarderImplementation: "",
forwarderFactory: "",
};

const WalletSimple = await ethers.getContractFactory("WalletSimple");
const walletSimple = await WalletSimple.deploy();
await walletSimple.deployed();
console.log("WalletSimple deployed to:", walletSimple.address);
output.walletImplementation = walletSimple.address;
console.log("WalletSimple deployed at " + walletSimple.address);

const WalletFactory = await ethers.getContractFactory("WalletFactory");
const walletFactory = await WalletFactory.deploy(walletSimple.address);
await walletFactory.deployed();
console.log("WalletFactory deployed to:", walletFactory.address);
output.walletFactory = walletFactory.address;
console.log("WalletFactory deployed at " + walletFactory.address);

const Forwarder = await ethers.getContractFactory("Forwarder");
const forwarder = await Forwarder.deploy();
await forwarder.deployed();
console.log("Forwarder deployed to:", forwarder.address);
output.forwarderImplementation = forwarder.address;
console.log("Forwarder deployed at " + forwarder.address);

const ForwarderFactory = await ethers.getContractFactory("ForwarderFactory");
const forwarderFactory = await ForwarderFactory.deploy(forwarder.address);
await forwarderFactory.deployed();
console.log("ForwarderFactory deployed to:", forwarderFactory.address);
output.forwarderFactory = forwarderFactory.address;
console.log("ForwarderFactory deployed at " + forwarderFactory.address);

fs.writeFileSync('output.json', JSON.stringify(output));

// We have to wait for a minimum of 10 block confirmations before we can call the etherscan api to verify
console.log("Waiting for 10 confirmations.....");
Expand All @@ -29,11 +44,13 @@ async function main() {
await forwarder.deployTransaction.wait(10);
await forwarderFactory.deployTransaction.wait(10);

console.log("Contracts confirmed on chain, .....");
console.log("Contracts confirmed on chain, verifying");
await verifyContract("WalletSimple", walletSimple.address, []);
await verifyContract("WalletFactory", walletFactory.address, [walletSimple.address]);
await verifyContract("Forwarder", forwarder.address, []);
await verifyContract("ForwarderFactory", forwarderFactory.address, [forwarder.address]);
console.log("Contracts verified");

}

async function verifyContract(contractName: string, contractAddress : string, constructorArguments : string[]) {
Expand Down

0 comments on commit dd0029d

Please sign in to comment.