1

I have an ERC721 contract that inherits ERC721URIStorage because I have to keep the URI on-chain. The problem I have is I am getting all these errors:

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

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

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

How can I fix this? How can I override this functions if I don't need them in my smart contract?

1 Answer 1

1

Solidity doesn't accept multiple inheritance with base class functions having the same name and same function arguments regardless of whether they're private or public.

This is a safety feature introduced with Solidity 0.6. The compiler asks you to tell it that you are aware of the fact that ERC721URIStorage also defines a function named "_beforeTokenTransfer" and that you want to ignore it. You have to add override(Base1, Base2) to the function header. Documentation: https://solidity.readthedocs.io/en/v0.7.1/contracts.html#function-overriding

Use something like :

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

Hope this helps!

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.