In hardhat-ethers we have these helper functions:
function deployContract(name: string, constructorArgs?: any[], signer?: ethers.Signer): Promise<ethers.Contract>;
function getContractFactory(name: string, signer?: ethers.Signer): Promise<ethers.ContractFactory>;
function getContractFactory(name: string, factoryOptions: FactoryOptions): Promise<ethers.ContractFactory>;
function getContractFactory(abi: any[], bytecode: ethers.utils.BytesLike, signer?: ethers.Signer): Promise<ethers.ContractFactory>;
function getContractAt(name: string, address: string, signer?: ethers.Signer): Promise<ethers.Contract>;
function getContractAt(abi: any[], address: string, signer?: ethers.Signer): Promise<ethers.Contract>;
function getSigners() => Promise<ethers.Signer[]>;
function getSigner(address: string) => Promise<ethers.Signer>;
function getImpersonatedSigner(address: string) => Promise<ethers.Signer>;
function getContractFactoryFromArtifact(artifact: Artifact, signer?: ethers.Signer): Promise<ethers.ContractFactory>;
function getContractFactoryFromArtifact(artifact: Artifact, factoryOptions: FactoryOptions): Promise<ethers.ContractFactory>;
function getContractAtFromArtifact(artifact: Artifact, address: string, signer?: ethers.Signer): Promise<ethers.Contract>;
My questions:
(1) Do I need to pass all parameters stated in function?
(2) We use ethers.getcontractFactory
like this const sample = await ethers.getcontractFactory("Sample")
, if we need to pass all parameters in function as stated then how this given example works??
(3) What is use of deployContract()
?? How to use it and when to use?
(4) In hardhat-ethers documentation they stated that The
Contract
s and
ContractFactory
s returned by these helpers are connected to the first signer returned by getSigners
by default.
Is that mean we don't need to worry about signer, we don't need to pass signer in funtion's parameter,signer is automatically set by default????