ERC721Royalty.sol 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // SPDX-License-Identifier: MIT
  2. // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/extensions/ERC721Royalty.sol)
  3. pragma solidity ^0.8.0;
  4. import "../ERC721.sol";
  5. import "../../common/ERC2981.sol";
  6. import "../../../utils/introspection/ERC165.sol";
  7. /**
  8. * @dev Extension of ERC721 with the ERC2981 NFT Royalty Standard, a standardized way to retrieve royalty payment
  9. * information.
  10. *
  11. * Royalty information can be specified globally for all token ids via {ERC2981-_setDefaultRoyalty}, and/or individually for
  12. * specific token ids via {ERC2981-_setTokenRoyalty}. The latter takes precedence over the first.
  13. *
  14. * IMPORTANT: ERC-2981 only specifies a way to signal royalty information and does not enforce its payment. See
  15. * https://eips.ethereum.org/EIPS/eip-2981#optional-royalty-payments[Rationale] in the EIP. Marketplaces are expected to
  16. * voluntarily pay royalties together with sales, but note that this standard is not yet widely supported.
  17. *
  18. * _Available since v4.5._
  19. */
  20. abstract contract ERC721Royalty is ERC2981, ERC721 {
  21. /**
  22. * @dev See {IERC165-supportsInterface}.
  23. */
  24. function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, ERC2981) returns (bool) {
  25. return super.supportsInterface(interfaceId);
  26. }
  27. /**
  28. * @dev See {ERC721-_burn}. This override additionally clears the royalty information for the token.
  29. */
  30. function _burn(uint256 tokenId) internal virtual override {
  31. super._burn(tokenId);
  32. _resetTokenRoyalty(tokenId);
  33. }
  34. }