I am deploying solidity contracts using Hardhat for which I have written this deploy script:
const { ethers } = require("hardhat");
async function main() {
const erc20Tokens = ["Solana", "USDC", "Doge"];
const initialSupply = ethers.utils.parseUnits("100", "ether");
async function deploy(token) {
const Token = await ethers.getContractFactory(token);
console.log(`deploying ERC20 ${token} contract...`);
const deployedToken = await Token.deploy(initialSupply);
await deployedToken.deployed();
return deployedToken.address;
// console.log(`deployed ERC20 ${token} at: `, deployedToken.address);
}
const resolveAllPromises = erc20Tokens.map(async (e) => deploy(e));
Promise.all(resolveAllPromises).then(e=>console.log("resolved",e)).catch(err=>console.log("err"))
}
main()
.then(() => process.exit(0))
.catch((err) => {
console.log("error: ", err);
process.exit(1);
});
I am not getting the returned value of deployedToken.address
from the deploy function even though the console.log in the deploy function is not executing. What's the issue here? May anyone help me out
return Promise.all
. You broke your promise chain.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.