forked from ZyntariHQ/Invoisio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.js
More file actions
40 lines (28 loc) · 1.21 KB
/
Copy pathdeploy.js
File metadata and controls
40 lines (28 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import hre from "hardhat";
import dotenv from "dotenv";
dotenv.config();
async function main() {
console.log("🚀 Starting deployment...");
// Connect to Mainnet network
const connection = await hre.network.connect({ network: "mainnet" });
// Get Viem instance
const { viem } = connection;
// Get deployer wallet
const [walletClient] = await viem.getWalletClients();
const deployerAddress = walletClient.account.address;
console.log("👤 Deployer address:", deployerAddress);
// Owner (can be different)
const OWNER_ADDRESS = process.env.INITIAL_OWNER || deployerAddress;
console.log("👑 Setting contract owner to:", OWNER_ADDRESS);
// Deploy contract
const deployment = await viem.deployContract("PaymentRouter", [OWNER_ADDRESS]);
// Depending on Viem version, either `deployment.contractAddress` or `deployment.address`
// Often you can read the actual address from the contract object returned:
const contractAddress = deployment.address || deployment.contractAddress;
console.log("✅ PaymentRouter deployed to:", contractAddress);
console.log("👑 Owner set to:", OWNER_ADDRESS);
}
main().catch((err) => {
console.error("❌ Deployment failed:", err);
process.exit(1);
});