// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import {ERC1155} from "openzeppelin-contracts/token/ERC1155/ERC1155.sol"; import {OperatorFilterer} from "../OperatorFilterer.sol"; import {Ownable} from "openzeppelin-contracts/access/Ownable.sol"; import {IERC2981, ERC2981} from "openzeppelin-contracts/token/common/ERC2981.sol"; /** * @title ExampleERC1155 * @notice This example contract is configured to use the DefaultOperatorFilterer, which automatically registers the * token and subscribes it to OpenSea's curated filters. * Adding the onlyAllowedOperator modifier to the transferFrom and both safeTransferFrom methods ensures that * the msg.sender (operator) is allowed by the OperatorFilterRegistry. */ abstract contract ExampleERC1155 is ERC1155, OperatorFilterer, Ownable, ERC2981 { bool public operatorFilteringEnabled; constructor() ERC1155("") { _registerForOperatorFiltering(); operatorFilteringEnabled = true; // Set royalty receiver to the contract creator, // at 5% (default denominator is 10000). _setDefaultRoyalty(msg.sender, 500); } function setApprovalForAll(address operator, bool approved) public override onlyAllowedOperatorApproval(operator) { super.setApprovalForAll(operator, approved); } function safeTransferFrom( address from, address to, uint256 tokenId, uint256 amount, bytes memory data ) public override onlyAllowedOperator(from) { super.safeTransferFrom(from, to, tokenId, amount, data); } function safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) public override onlyAllowedOperator(from) { super.safeBatchTransferFrom(from, to, ids, amounts, data); } function supportsInterface(bytes4 interfaceId) public view virtual override(ERC1155, ERC2981) returns (bool) { // Supports the following `interfaceId`s: // - IERC165: 0x01ffc9a7 // - IERC1155: 0xd9b67a26 // - IERC1155MetadataURI: 0x0e89341c // - IERC2981: 0x2a55205a return ERC1155.supportsInterface(interfaceId) || ERC2981.supportsInterface(interfaceId); } function setDefaultRoyalty(address receiver, uint96 feeNumerator) public onlyOwner { _setDefaultRoyalty(receiver, feeNumerator); } function setOperatorFilteringEnabled(bool value) public onlyOwner { operatorFilteringEnabled = value; } function _operatorFilteringEnabled() internal view override returns (bool) { return operatorFilteringEnabled; } function _isPriorityOperator(address operator) internal pure override returns (bool) { // OpenSea Seaport Conduit: // https://etherscan.io/address/0x1E0049783F008A0085193E00003D00cd54003c71 // https://goerli.etherscan.io/address/0x1E0049783F008A0085193E00003D00cd54003c71 return operator == address(0x1E0049783F008A0085193E00003D00cd54003c71); } }