0

I am trying to make a simple nft smart contract that only allows the wallet owner to mint nfts

 pragma solidity ^0.8.15;

 import "erc721a/contracts/ERC721A.sol";

 contract testNFTRun is ERC721A {

     constructor() ERC721("testNFTRun", "TNFTR") {}


     function mint(uint256 quantity) external payable {
         // `_mint`'s second argument now takes in a `quantity`, not a `tokenId`.
         require(msg.sender == ownerOf(), "Only contract owner can mint NFTs");
         _mint(msg.sender, quantity);
     }


       function _baseURI() override internal view virtual returns (string memory) {
         return "ipfs://bafybeifgxh2lo3jpx6xg2bl3wlnifgpahcdvmktl42jz7d7m7x7y6yap3i/";
     }
 }

I am getting this error compiling the smart contract

 DeclarationError: Identifier not found or not unique.
 --> noot.sol:14:19:
 |
 14 | constructor() ERC721("testNFTRun", "TNFTR") {}
 | ^^^^^^

Probably something with how I am importing the erc721a contracts but I cant find any issues

2 Answers 2

0

The error message you received suggests that the ERC721 identifier is not found or not unique, which could be due to a few possible reasons:

  1. The ERC721 contract needs to be correctly imported. Please ensure your import statement has the correct path to the ERC721 contract.

  2. The ERC721 contract has a different name or is defined differently than expected. Could you check the actual code of the ERC721 the contract you are importing to ensure it has the same name and function signatures as your contract expects?

Based on the code you provided, you are importing from a package named erc721a. If you are using a third-party package, please ensure you have installed it correctly and that it is available in your project's environment.

If none of the above solutions work, could you give more details or post the code of the ERC721 contract you are importing, so we can help you better?

0

As per the documentation (it seems you forgot the ERC721A in the constructor):

pragma solidity ^0.8.4;

import "erc721a/contracts/ERC721A.sol";

contract Azuki is ERC721A {
    constructor() ERC721A("Azuki", "AZUKI") {}

    function mint(uint256 quantity) external payable {
        // `_mint`'s second argument now takes in a `quantity`, not a `tokenId`.
        _mint(msg.sender, quantity);
    }
}

https://github.com/chiru-labs/ERC721A

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.