40 lines
1.4 KiB
TypeScript
40 lines
1.4 KiB
TypeScript
import { ethers } from "hardhat";
|
|
|
|
async function main() {
|
|
const [deployer] = await ethers.getSigners();
|
|
|
|
console.log("Deploying contracts with the account:", deployer.address);
|
|
console.log("Account balance:", (await ethers.provider.getBalance(deployer.address)).toString());
|
|
|
|
// Deploy SubAccountFactory
|
|
const SubAccountFactory = await ethers.getContractFactory("SubAccountFactory");
|
|
const factory = await SubAccountFactory.deploy();
|
|
await factory.waitForDeployment();
|
|
const factoryAddress = await factory.getAddress();
|
|
console.log("SubAccountFactory deployed to:", factoryAddress);
|
|
|
|
// Example: Deploy a TreasuryWallet with initial owners
|
|
// In production, this would be done by the frontend when a user creates a treasury
|
|
const owners = [deployer.address]; // Replace with actual owners
|
|
const threshold = 1;
|
|
|
|
const TreasuryWallet = await ethers.getContractFactory("TreasuryWallet");
|
|
const treasury = await TreasuryWallet.deploy(owners, threshold);
|
|
await treasury.waitForDeployment();
|
|
const treasuryAddress = await treasury.getAddress();
|
|
console.log("TreasuryWallet deployed to:", treasuryAddress);
|
|
|
|
console.log("\nDeployment Summary:");
|
|
console.log("===================");
|
|
console.log("SubAccountFactory:", factoryAddress);
|
|
console.log("Example TreasuryWallet:", treasuryAddress);
|
|
}
|
|
|
|
main()
|
|
.then(() => process.exit(0))
|
|
.catch((error) => {
|
|
console.error(error);
|
|
process.exit(1);
|
|
});
|
|
|