0

I am triying to deploy mi ERC721 contract in my private Blockchian. This is the Smart Contract:

// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.9.0;


import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Counters.sol";

contract MyToken is ERC721, ERC721Enumerable, ERC721URIStorage, ERC721Burnable, Ownable {
    using Counters for Counters.Counter;

    Counters.Counter private _tokenIdCounter;

    constructor() ERC721("MyToken", "MTK") {}

    function safeMint(address to, string memory uri) public onlyOwner {
        uint256 tokenId = _tokenIdCounter.current();
        _tokenIdCounter.increment();
        _safeMint(to, tokenId);
        _setTokenURI(tokenId, uri);
    }

    // The following functions are overrides required by Solidity.

    function _beforeTokenTransfer(address from, address to, uint256 tokenId)
        internal
        override(ERC721, ERC721Enumerable)
    {
        super._beforeTokenTransfer(from, to, tokenId);
    }

    function _burn(uint256 tokenId) internal override(ERC721, ERC721URIStorage) {
        super._burn(tokenId);
    }

    function tokenURI(uint256 tokenId)
        public
        view
        override(ERC721, ERC721URIStorage)
        returns (string memory)
    {
        return super.tokenURI(tokenId);
    }

    function supportsInterface(bytes4 interfaceId)
        public
        view
        override(ERC721, ERC721Enumerable)
        returns (bool)
    {
        return super.supportsInterface(interfaceId);
    }
}

However, when running

truffle migrate --reset 

I am getting the following error:

Error parsing @openzeppelin/contracts/token/ERC721/ERC721.sol: ParsedContract.sol:54:28: ParserError: Expected primary expression.
            interfaceId == type(IERC721).interfaceId ||
                           ^--^

Compilation failed. See above. This is not the first time in running this migration. However, it is the first time it is not succesful. Does anyone know why I am getting this error? Thanks

WakiApi
  • 25
  • 5
  • Did you make any changes to the imported `ERC721.sol` file? It seems like there is some unexpected whitespace character (e.g. the non-break space instead of a regular one) before the `type` keyword. – Petr Hejda Sep 12 '22 at 10:18
  • No, I didn’t make any changes. Could it be caused by Truffle compiler? I am using Truffle 4.1.5 and 0.8.4 compiler – WakiApi Sep 12 '22 at 20:59

0 Answers0