-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathExampleERC721A.sol
99 lines (87 loc) · 3.33 KB
/
ExampleERC721A.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import {IERC721A, ERC721A} from "erc721a/ERC721A.sol";
import {ERC721AQueryable} from "erc721a/extensions/ERC721AQueryable.sol";
import {ERC721ABurnable} from "erc721a/extensions/ERC721ABurnable.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 ExampleERC721A
* @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 ExampleERC721A is
ERC721AQueryable,
ERC721ABurnable,
OperatorFilterer,
Ownable,
ERC2981
{
bool public operatorFilteringEnabled;
constructor() ERC721A("Example", "EXAMPLE") {
_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(IERC721A, ERC721A)
onlyAllowedOperatorApproval(operator)
{
super.setApprovalForAll(operator, approved);
}
function approve(address operator, uint256 tokenId)
public
payable
override(IERC721A, ERC721A)
onlyAllowedOperatorApproval(operator)
{
super.approve(operator, tokenId);
}
/**
* @dev Both safeTransferFrom functions in ERC721A call this function
* so we don't need to override them.
*/
function transferFrom(address from, address to, uint256 tokenId)
public
payable
override(IERC721A, ERC721A)
onlyAllowedOperator(from)
{
super.transferFrom(from, to, tokenId);
}
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(IERC721A, ERC721A, ERC2981)
returns (bool)
{
// Supports the following `interfaceId`s:
// - IERC165: 0x01ffc9a7
// - IERC721: 0x80ac58cd
// - IERC721Metadata: 0x5b5e139f
// - IERC2981: 0x2a55205a
return ERC721A.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);
}
}