1

im doing step by step of this article and i had a problem on truffle compile part. I've got this error in cmd:

Error parsing @openzeppelin/contracts/token/ERC721/ERC721.sol: ParsedContract.sol:51:72: ParserError: Expected '{' but got reserved keyword 'override'
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
                                                                   ^------^

my contract :

pragma solidity ^0.6.0;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/utils/Counters.sol";

contract Uniken is ERC721{

using Counters for Counters.Counter;
Counters.Counter private _tokenIds;
mapping(string => uint8) hashes;


  constructor() public ERC721("Uniken", "Ukn") {
   }
  
  function awardItem(address recipient, string memory hash, string memory metadata)
  public
  returns (uint256)

  {  
      require(hashes[hash] != 1);
        hashes[hash] = 1;  
        _tokenIds.increment(); 
        uint256 newItemId = _tokenIds.current(); 
        _mint(recipient, newItemId); 
        _setTokenURI(newItemId, metadata);  
        return newItemId;
  }

}

I'd be thankfull if anyone tell me whatis the problem?

4

2 回答 2

1

似乎没有看到 ERC721 扩展的 ERC165 合同。它卡住的那个函数应该覆盖 ERC165 中的同名函数,但是 truffle 编译器在 ERC721 继承的类中没有看到名为 supportsInterface() 的函数。所以我会检查以确保在 ERC721 智能合约中导入的所有内容都在您的文件夹结构中的正确位置,并且 ERC721 正确继承了 ERC165。

于 2021-08-03T16:49:20.777 回答
0

经过一番研究,我在 truffle 版本 5.0 并更新到最新版本的 truffle -> v5.4.6,我现在可以编译了

于 2021-08-14T10:03:32.913 回答