'What's the difference between .deploy() vs. .deployed()
I am writing a script for a smart contract that I'll deploy using hardhat. I'm confused on the difference between .deploy() and .deployed(), what does each one do?
const main = async () => {
const waveContractFactory = await hre.ethers.getContractFactory('WavePortal');
const waveContract = await waveContractFactory.deploy();
await waveContract.deployed();
console.log('Contract addy:', waveContract.address);
...
Solution 1:[1]
deploy()
will trigger this deployment of the contract and deployed()
checks if the contract is already available on the blockchain and if the deployment is still ongoing will wait for the deployment transaction to be mined.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Josep Bové |