ERC721RoyaltyUpgradeable.sol 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // SPDX-License-Identifier: MIT
  2. // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/ERC721Royalty.sol)
  3. pragma solidity ^0.8.0;
  4. import "../ERC721Upgradeable.sol";
  5. import "../../common/ERC2981Upgradeable.sol";
  6. import "../../../utils/introspection/ERC165Upgradeable.sol";
  7. import "../../../proxy/utils/Initializable.sol";
  8. /**
  9. * @dev Extension of ERC721 with the ERC2981 NFT Royalty Standard, a standardized way to retrieve royalty payment
  10. * information.
  11. *
  12. * Royalty information can be specified globally for all token ids via {_setDefaultRoyalty}, and/or individually for
  13. * specific token ids via {_setTokenRoyalty}. The latter takes precedence over the first.
  14. *
  15. * IMPORTANT: ERC-2981 only specifies a way to signal royalty information and does not enforce its payment. See
  16. * https://eips.ethereum.org/EIPS/eip-2981#optional-royalty-payments[Rationale] in the EIP. Marketplaces are expected to
  17. * voluntarily pay royalties together with sales, but note that this standard is not yet widely supported.
  18. *
  19. * _Available since v4.5._
  20. */
  21. abstract contract ERC721RoyaltyUpgradeable is Initializable, ERC2981Upgradeable, ERC721Upgradeable {
  22. function __ERC721Royalty_init() internal onlyInitializing {
  23. }
  24. function __ERC721Royalty_init_unchained() internal onlyInitializing {
  25. }
  26. /**
  27. * @dev See {IERC165-supportsInterface}.
  28. */
  29. function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721Upgradeable, ERC2981Upgradeable) returns (bool) {
  30. return super.supportsInterface(interfaceId);
  31. }
  32. /**
  33. * @dev See {ERC721-_burn}. This override additionally clears the royalty information for the token.
  34. */
  35. function _burn(uint256 tokenId) internal virtual override {
  36. super._burn(tokenId);
  37. _resetTokenRoyalty(tokenId);
  38. }
  39. /**
  40. * This empty reserved space is put in place to allow future versions to add new
  41. * variables without shifting down storage in the inheritance chain.
  42. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
  43. */
  44. uint256[50] private __gap;
  45. }