Skip to content

Commit f4515d2

Browse files
committed
make gas and price more predictable
1 parent 9e27ffb commit f4515d2

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

scripts/utility/deployment.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1+
import { utils, Wallet, ContractFactory } from "ethers"
12
import { ethers } from "hardhat"
2-
import { gasLimit, gasPrice } from "./constants"
3-
import { utils, Wallet } from "ethers"
43

54
export const deploy = async <T>(contractName: string, ...args: any[]): Promise<T> => {
6-
const Contract = await ethers.getContractFactory(contractName)
5+
const Contract: ContractFactory = await ethers.getContractFactory(contractName)
6+
console.log(`Deploying ${contractName}...`)
7+
const unsignedTx = Contract.getDeployTransaction(...args)
8+
const gasLimit = await ethers.provider.estimateGas(unsignedTx)
9+
console.log(`Gas limit for ${contractName}: ${gasLimit}`)
10+
const gasPrice = await ethers.provider.getGasPrice()
11+
console.log(`Gas price: ${gasPrice.toString()}`)
712
const contract = await Contract.deploy(...args, { gasLimit, gasPrice })
813
console.log(`${contractName} deployed at: ${contract.address}`)
914
return contract.deployed() as Promise<T>

0 commit comments

Comments
 (0)