That error means youâre trying to use the Dao
variable before youâve declared/created it (with const Dao
). Check your deploy script.
Put it there before now same error
Youâre trying to use Dao.deploy()
, this should be named something else since youâre trying to declare another variable of the same name with const Dao
. Can you post your deploy script?
Sure
// We require the Hardhat Runtime Environment explicitly here. This is optional
// but useful for running the script in a standalone fashion through node <script>
.
//
// You can also run a script with npx hardhat run <script>
. If you do that, Hardhat
// will compile your contracts, add the Hardhat Runtime Environmentâs members to the
// global scope, and execute the script.
const hre = require(âhardhatâ);
async function main() {
const currentTimestampInSeconds = Math.round(Date.now() / 1000);
const ONE_YEAR_IN_SECS = 365 * 24 * 60 * 60;
const unlockTime = currentTimestampInSeconds + ONE_YEAR_IN_SECS;
const lockedAmount = hre.ethers.utils.parseEther(â1â);
const Dao = await Dao.deploy();
hre.ethers.getContractFactory(âDaoâ);
await lock.deployed();
console.log(
Lock with 1 ETH and unlock timestamp ${unlockTime} deployed to ${lock.address}
);
}
// We recommend this pattern to be able to use async/await everywhere
// and properly handle errors.
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
You can read this on how to post code.
There is no Dao
defined anywhere when you try to use Dao.deploy()
. Did you follow a guide or tutorial for this particular script?
You can look at this guide for how to set up contract instances in your scripts.
So something like:
const Dao = await hre.ethers.getContractFactory("Dao");
const dao = await Dao.deploy();