When i tried running this command, I have previously ran npx hardhat clean
and npx hardhat compile
. I have the following error:
npx hardhat run scripts/deployRoboPunksNFT.js --network sepolia
TypeError: roboPunksNFT.deployed is not a function
at main (/home/stanley/Documents/full-mint-website/scripts/deployRoboPunksNFT.js:7:22)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
and other times i have a connection timeout:
Error: Socket connection timeout
at new NodeError (node:internal/errors:399:5)
at internalConnectMultiple (node:net:1099:20)
at Timeout.internalConnectMultipleTimeout (node:net:1638:3)
at listOnTimeout (node:internal/timers:575:11)
at processTimers (node:internal/timers:514:7) {
code: 'ERR_SOCKET_CONNECTION_TIMEOUT'
}
My deployRoboPunksNFT.js script
const hre = require("hardhat");
async function main() {
const RoboPunksNFT = await hre.ethers.getContractFactory("RoboPunksNFT");
const roboPunksNFT = await RoboPunksNFT.deploy();
await roboPunksNFT.deployed();
console.log("RoboPunksNFT deployed to:", roboPunksNFT.address);
}
// We recommend this pattern to be able to use async/await everywhere
// and properly handle errors.
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
My hardhat config
require("@nomicfoundation/hardhat-toolbox");
const dotenv = require("dotenv");
dotenv.config();
/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
solidity: "0.8.19",
networks: {
sepolia: {
url: process.env.REACT_APP_SEPOLIA_URL,
accounts: [process.env.REACT_APP_PRIVATE_KEY],
},
},
apiKey: process.env.REACT_APP_ETHERSCAN_KEY,
};
How do i solve this issue ?
deployed()
and address
is depreciated.
Make these changes:
deployed()
to waitForDeployment()
AND
console.log("RoboPunksNFT deployed to:", roboPunksNFT.address);
to
console.log("RoboPunksNFT deployed to:",await roboPunksNFT.getAddress());