0
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.4;

import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155URIStorage.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Supply.sol";

contract MyToken is ERC1155, ERC1155URIStorage, Ownable, ERC1155Supply {
constructor() ERC1155("") {}

function mint(address account, uint256 id, uint256 amount, bytes memory data)
    public
    onlyOwner
{
    _mint(account, id, amount, data);
}

function mintBatch(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data)
    public
    onlyOwner
{
    _mintBatch(to, ids, amounts, data);
}

// The following functions are overrides required by Solidity.

function _beforeTokenTransfer(address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data)
    internal
    override(ERC1155, ERC1155Supply)
{
    super._beforeTokenTransfer(operator, from, to, ids, amounts, data);
}
}

enter image description here

I'm getting this error in remix....any help ?

1 Answer 1

0

First, ERC1155URIStorage and ERC1155Supply inherit from ERC1155, so you do not need to declare ERC1155 as an additional parent of your MyToken contract.

The error occurs because both ERC1155URIStorage and ERC1155 (imported through your additional declaration and through ERC1155Supply) define a function with the same signature:

function uri(uint256 tokenId) public view virtual override returns (string memory)

In order to fix this, you probably need to override the function again in case you really need the ERC1155Supply extension as well.

function uri(uint256 tokenId) public view override(ERC1155, ERC1155URIStorage) returns (string memory) {
    return ERC1155URIStorage.uri(tokenId);
}

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.