SyntaxError: Identifier has already been declared #3783
Unanswered
margilazde
asked this question in
Troubleshooting
Replies: 1 comment
-
It should be
Since you already declare MyNFT variable with |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
An error occurred after this code npx hardhat --network arbitrum_goerli run scripts/deploy.js
Error: SyntaxError: Identifier 'nameofmyfile' has already been declared
how to fix it please help me
MY CONTRACT
//Contract based on https://docs.openzeppelin.com/contracts/3.x/erc721
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
contract StrangeGeeseClub is ERC721URIStorage, Ownable {
using Counters for Counters.Counter;
Counters.Counter private _tokenIds;
constructor() ERC721("StrangeGeeseClub", "SG") {}
function mintNFT(address recipient, string memory tokenURI)
public onlyOwner
returns (uint256)
{
_tokenIds.increment();
uint256 newItemId = _tokenIds.current();
_mint(recipient, newItemId);
_setTokenURI(newItemId, tokenURI);
return newItemId;
}
}
MY DEPLOY CODE
async function main() {
const MyNFT = await ethers.getContractFactory("MyNFT");
// Start deployment, returning a promise that resolves to a contract object
const MyNFT = await MyNFT.deploy();
await MyNFT.deployed();
console.log("Contract deployed to address:", MyNFT.address);
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
Beta Was this translation helpful? Give feedback.
All reactions