1

've just started learning solidity and I tried to make a contract .

I getting error due to totalSupply() are Undeclared identified .

contract BYYCC is ERC721, Ownable {

    using SafeMath for uint256;

    string public BAYC_PROVENANCE = "";

    uint256 public startingIndexBlock;

    uint256 public startingIndex;

    uint256 public constant apePrice = 80000000000000000; //0.08 ETH

    uint public constant maxApePurchase = 20;

    uint256 public MAX_APES;

    bool public saleIsActive = false;

    uint256 public REVEAL_TIMESTAMP;

    constructor(string memory name, string memory symbol, uint256 maxNftSupply, uint256 saleStart) ERC721(name, symbol) {
        MAX_APES = maxNftSupply;
        REVEAL_TIMESTAMP = saleStart + (86400 * 9);
    }

enter image description here

I 've try import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol" .it resolve the totalSupply() are Undeclared identified but another Error when inherit from ERC721Enumerable and ERC721 at the same time

Derived contract must override function "_beforeTokenTransfer". Two or more base classes define function with same name and parameter types.

Derived contract must override function "supportsInterface". Two or more base classes define function with same name and parameter types.

enter image description here

1 Answer 1

1

That's because ERC721Enumerable already inherits from ERC721. For this reason, functions are colliding. To solve this, just import ERC721Enumerable in your contract like so:

contract BYYCC is ERC721Enumerable, Ownable {

}
1
  • Thanks you ! sorry am newbie and not familiar .seem like a stupid question
    – brook18
    Mar 6, 2022 at 12:03

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.