Created
June 5, 2024 06:34
-
-
Save ipekt/2b7a140fe35cb54a1fce13004c972645 to your computer and use it in GitHub Desktop.
OAL implementation example for ERC1155
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // SPDX-License-Identifier: UNLICENSED | |
| pragma solidity 0.8.19; | |
| import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; | |
| import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; | |
| import {OperatorAllowlistEnforced} from "@imtbl/contracts/contracts/allowlist/OperatorAllowlistEnforced.sol"; | |
| contract ClashOfCats1155 is ERC1155, Ownable, OperatorAllowlistEnforced { | |
| constructor( | |
| string memory baseTokenURI, | |
| address operatorAllowlist_ // OAL contract address | |
| ) ERC1155(baseTokenURI) Ownable() { | |
| _setOperatorAllowlistRegistry(operatorAllowlist_); | |
| } | |
| function _safeTransferFrom( | |
| address from, | |
| address to, | |
| uint256 id, | |
| uint256 value, | |
| bytes memory data | |
| ) internal override validateTransfer(from, to) { | |
| super._safeTransferFrom(from, to, id, value, data); | |
| } | |
| function _safeBatchTransferFrom( | |
| address from, | |
| address to, | |
| uint256[] memory ids, | |
| uint256[] memory values, | |
| bytes memory data | |
| ) internal override validateTransfer(from, to) { | |
| super._safeBatchTransferFrom(from, to, ids, values, data); | |
| } | |
| function setApprovalForAll( | |
| address operator, | |
| bool approved | |
| ) public override(ERC1155) validateApproval(operator) { | |
| super.setApprovalForAll(operator, approved); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment