File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change
1
+ import { utils , Wallet , ContractFactory } from "ethers"
1
2
import { ethers } from "hardhat"
2
- import { gasLimit , gasPrice } from "./constants"
3
- import { utils , Wallet } from "ethers"
4
3
5
4
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 ( ) } ` )
7
12
const contract = await Contract . deploy ( ...args , { gasLimit, gasPrice } )
8
13
console . log ( `${ contractName } deployed at: ${ contract . address } ` )
9
14
return contract . deployed ( ) as Promise < T >
You can’t perform that action at this time.
0 commit comments