Solidity

ERC721Burnable TypeError:基礎的定義必須先於派生合約的定義

  • September 13, 2021

由於 Burnable,我收到了一個錯誤,但它甚至不在我的契約中。

@openzeppelin/contracts/token/ERC721/ERC721Burnable.sol:12:46:

abstract contract ERC721Burnable is Context, ERC721
                                            ^----^

ERC-721 契約

pragma solidity ^0.6.0;

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

contract MyContract is ERC721 {

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

   constructor() ERC721("MYNFT", "MNT") public {
   }

   function CID(uint256 tokenId) public view returns (string memory) {

     require(_exists(tokenId), "ERC721Metadata: CID query for nonexistent token");
     string memory _CID = _CIDS[tokenId];

     return _CID;
   }

   function _setTokenCID(uint256 tokenId, string memory _CID) internal virtual {
     require(_exists(tokenId), "ERC721Metadata: CID set of nonexistent token");
     _CIDS[tokenId] = _CID;
   }

   function mint(string memory _CID, string memory metadata) public {
     require(hashes[_CID] != 1);
     hashes[_CID] = 1;

     uint256 _newId = totalSupply() + 1;
     _safeMint(msg.sender, _newId);
     _setTokenCID(_newId, _CID);

     _setTokenURI(_newId, metadata);
     
   }
   
}

npm install @openzeppelin/contracts

我重新安裝了開放的 zeppelin 契約,並且有效。

引用自:https://ethereum.stackexchange.com/questions/109754