Derived contract must override function "supportsInterface"

When inheriting from both ERC1155 and AccessControl I receive the error in the following error:

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

:computer: Environment

OpenZeppeling 4.0.0-beta.0

:memo:Details

:1234: Code to reproduce

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";

contract MyContract is ERC1155, AccessControl { }
2 Likes

Hi @dylkil,

Welcome to the community :wave:

As both ERC1155 and AccessControl include supportsInterface we need to override both.

The following compiles:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";

contract MyContract is ERC1155, AccessControl { 

    constructor (string memory uri) ERC1155(uri) {}

    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC1155, AccessControl) returns (bool) {
        return super.supportsInterface(interfaceId);
    }
}
3 Likes