< im getting this error when trying to deploy and compile my ERC721UUPS upgradbale contract in hardhat
im running
npx hardhat run scripts/deploy.js --network localhost
Error HH404: File @openzeppelin/contracts/security/ReentrancyGuard.sol, imported from contracts/NFTV1.sol, not found.
For more info go to https://hardhat.org/HH404 or run Hardhat with --show-stack-traces
PS C:\Users\dillo\hardhatupgradesnewest> -->
Code to reproduce
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20BurnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20PausableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20PermitUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20VotesUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
contract ERC20V1 is Initializable, ERC20Upgradeable, ERC20BurnableUpgradeable, ERC20PausableUpgradeable, OwnableUpgradeable, ERC20PermitUpgradeable, ERC20VotesUpgradeable, UUPSUpgradeable {
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
_disableInitializers();
}
function initialize(address initialOwner) initializer public {
__ERC20_init("Version1", "V1");
__ERC20Burnable_init();
__ERC20Pausable_init();
__Ownable_init(initialOwner);
__ERC20Permit_init("Version1");
__ERC20Votes_init();
__UUPSUpgradeable_init();
_mint(msg.sender, 1000 * 10 ** decimals());
}
// Minting function allows the owner to create new tokens and assign them to a specific address.
function mint(address to, uint256 amount) public onlyOwner {
_mint(to, amount);
}
// A function for transferring ownership of the contract.
function transferOwnership(address newOwner) public override onlyOwner {
_transferOwnership(newOwner);
}
// Pause and unpause the token transfers, useful for emergency situations.
function pause() public onlyOwner {
_pause();
}
function unpause() public onlyOwner {
_unpause();
}
// Override the upgrade authorization function to allow only the owner to upgrade.
function _authorizeUpgrade(address newImplementation) internal onlyOwner override {}
// The following functions are overrides required by Solidity.
function _update(address from, address to, uint256 value) internal override(ERC20Upgradeable, ERC20PausableUpgradeable, ERC20VotesUpgradeable) {
super._update(from, to, value);
}
function nonces(address owner) public view override(ERC20PermitUpgradeable, NoncesUpgradeable) returns (uint256) {
return super.nonces(owner);
}
}
require('@openzeppelin/hardhat-upgrades');
module.exports = {
solidity: {
version: "0.8.22", // Add other versions as needed
settings: {
outputSelection: {
"*": {
"*": ["*"],
},
},
},
},
paths: {
sources: "./contracts", // This should point to your "contracts" directory.
},
networks: {
localhost: {
chainId: 31337, // Set the chain ID to 31337 for your local network.
},
songbird: {
gas: "auto",
gasPrice: "auto",
gasMultiplier: 1,
url: "https://sgb.ftso.com.au/ext/bc/C/rpc",
chainId: 19,
accounts: [ACCOUNT],
},
goerli: {
gas: "auto",
gasPrice: "auto",
gasMultiplier: 1,
url: "https://ethereum-goerli.publicnode.com",
chainId: 5,
accounts: [ACCOUNT],
},
},
};
{
"name": "hardhatupgradesnewest",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@nomicfoundation/hardhat-ethers": "^3.0.4",
"@openzeppelin/hardhat-upgrades": "^2.3.3",
"ethers": "^6.8.1",
"hardhat": "^2.19.0"
},
"dependencies": {
"@openzeppelin/contracts-upgradeable": "^5.0.0"
}
}
const { ethers, upgrades } = require("hardhat");
async function main() {
try {
// Deploying the initial contract
const Box = await ethers.getContractFactory("NFTV1");
console.log("Creating a contract factory for Test", await Box );
const box = await upgrades.deployProxy(Box, ["0x2546BcD3c84621e976D8185a91A922aE77ECEc30"], { kind: 'uups' });
console.log("Deploying proxy contract for Test");
await box.waitForDeployment();
console.log("Box deployed to:", await box.getAddress());
} catch (error) {
console.error("Error:", error);
}
}
main();