ERC1155Supply compilation error

I tried to compile ERC1155Supply with ERC1155 token with hardhat and got the code from OZ wizard this is the error i get

TypeError: Invalid contract specified in override list: "ERC1155Supply".
   --> contracts/Proposal.sol:206:9:
    |
206 |         override(ERC1155, ERC1155Supply)
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Note: This contract: 
  --> @openzeppelin/contracts/token/ERC1155/extensions/ERC1155Supply.sol:16:1:
   |
16 | abstract contract ERC1155Supply is ERC1155 {
   | ^ (Relevant source part starts here and spans across multiple lines).


Error HH600: Compilation failed

Also this is the change i did in beforeTokenTransfer and afterTokenTransfer Hooks

function _afterTokenTransfer(address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data)
        internal
        override(ERC1155, ERC1155Supply)
    {
        super._afterTokenTransfer(operator, from, to, ids, amounts, data);
        if(from != address(0) && to != address(0)){
            if(balanceOf(from, ids[0]) == 0){
              removeHolder(from, ids[0]);
            } else {
              reduceBalance(from, ids[0]);
            }
        } else if(to == address(0)){
           if(balanceOf(from, ids[0]) == 0){
              removeHolder(from, ids[0]);
            } else {
              reduceBalance(from, ids[0]);
            } 
        }
    }

openzeppelin version 4.7.3

In _afterTokenTransfer try removing ERC1155Supply from override(ERC1155, ERC1155Supply).

1 Like

Thanks, worked but why it just affects afterTransferToken ?

_afterTokenTransfer is not modified by ERC1155Supply while _beforeTokenTransfer is.

1 Like