From 705ad2129ad31792f962b292646bbb530e2729bb Mon Sep 17 00:00:00 2001 From: Marc Doerflinger Date: Thu, 23 May 2024 13:52:07 +0000 Subject: [PATCH] calculate create2 address --- scripts/libs/deployment.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/libs/deployment.ts b/scripts/libs/deployment.ts index f1231e702..a226f08a9 100644 --- a/scripts/libs/deployment.ts +++ b/scripts/libs/deployment.ts @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ -import { AddressLike, BaseContract, Signer, TransactionReceipt, TransactionResponse, resolveAddress } from "ethers"; +import { AddressLike, BaseContract, Signer, TransactionReceipt, TransactionResponse, id, keccak256, resolveAddress } from "ethers"; import hre, { ethers } from "hardhat"; import { logger } from "../logger"; import { deploymentState, isResumeableDeployment } from "./deployment_state"; @@ -133,6 +133,9 @@ async function executeAllDeploymentSteps(contractName: string, signer: Signer, c logger.info(`Deploying ${contractName}...`); const factoryArgs = factoryOptions != undefined ? { ...factoryOptions, signer } : { signer }; const contractFactory = await ethers.getContractFactory(contractName, factoryArgs); + logger.debug(contractFactory.bytecode); + const c2Address = ethers.getCreate2Address(await resolveAddress(signer.getAddress()), id("HelloWorld"), keccak256(contractFactory.bytecode)); + console.log("c2Address: ", c2Address); const opts = {} as any; if (GAS_PRICE !== undefined) {