MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / deployContract

Function deployContract

kms/auth-eth/scripts/deploy.ts:9–67  ·  view source on GitHub ↗
(hre: HardhatRuntimeEnvironment, contractName: string, initializerArgs: any[] = [], quiet: boolean = false, initializer?: string)

Source from the content-addressed store, hash-verified

7
8// This function should be called directly by Hardhat tasks
9export async function deployContract(hre: HardhatRuntimeEnvironment, contractName: string, initializerArgs: any[] = [], quiet: boolean = false, initializer?: string) {
10 try {
11 function log(...msgs: any[]) {
12 if (!quiet) {
13 console.log(...msgs);
14 }
15 }
16
17 log(`Starting ${contractName} deployment process...`);
18
19 if (!quiet) {
20 // Get network info
21 await helpers.logNetworkInfo(hre);
22 }
23
24 log("Getting contract factory...");
25 const contractFactory = await hre.ethers.getContractFactory(contractName);
26
27 if (!quiet) {
28 // Estimate gas for deployment
29 await helpers.estimateDeploymentCost(
30 hre,
31 contractName,
32 initializerArgs,
33 initializer
34 );
35
36 // Prompt for confirmation
37 if (!(await helpers.confirmAction('Do you want to proceed with deployment?'))) {
38 log('Deployment cancelled');
39 return;
40 }
41 }
42
43 // Deploy using proxy pattern
44 log("Deploying proxy...");
45 const contract = await hre.upgrades.deployProxy(contractFactory,
46 initializerArgs,
47 { kind: 'uups', ...(initializer ? { initializer } : {}) }
48 );
49 log("Waiting for deployment...");
50 await contract.waitForDeployment();
51
52 const address = await contract.getAddress();
53 log(`${contractName} Proxy deployed to:`, address);
54
55 // Verify deployment
56 await helpers.verifyDeployment(hre, address, quiet);
57
58 const tx = await contract.deploymentTransaction();
59 log("Deployment completed successfully");
60 log("Transaction hash:", tx?.hash);
61
62 return contract;
63 } catch (error) {
64 console.error("Error during deployment:", error);
65 throw error;
66 }

Callers 4

hardhat.config.tsFile · 0.90
DstackApp.test.tsFile · 0.90
setup.tsFile · 0.90
mainFunction · 0.85

Calls 3

logFunction · 0.85
getContractFactoryMethod · 0.80
waitForDeploymentMethod · 0.65

Tested by

no test coverage detected