IERC721.sol 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. pragma solidity ^0.6.2;
  2. import "../../introspection/IERC165.sol";
  3. /**
  4. * @dev Required interface of an ERC721 compliant contract.
  5. */
  6. interface IERC721 is IERC165 {
  7. /**
  8. * @dev Emitted when `tokenId` token is transfered from `from` to `to`.
  9. */
  10. event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
  11. /**
  12. * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
  13. */
  14. event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
  15. /**
  16. * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
  17. */
  18. event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
  19. /**
  20. * @dev Returns the number of tokens in ``owner``'s account.
  21. */
  22. function balanceOf(address owner) external view returns (uint256 balance);
  23. /**
  24. * @dev Returns the owner of the `tokenId` token.
  25. *
  26. * Requirements:
  27. *
  28. * - `tokenId` must exist.
  29. */
  30. function ownerOf(uint256 tokenId) external view returns (address owner);
  31. /**
  32. * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
  33. * are aware of the ERC721 protocol to prevent tokens from being forever locked.
  34. *
  35. * Requirements:
  36. *
  37. * - `from`, `to` cannot be zero.
  38. * - `tokenId` token must exist and be owned by `from`.
  39. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
  40. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
  41. *
  42. * Emits a {Transfer} event.
  43. */
  44. function safeTransferFrom(address from, address to, uint256 tokenId) external;
  45. /**
  46. * @dev Transfers `tokenId` token from `from` to `to`.
  47. *
  48. * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
  49. *
  50. * Requirements:
  51. *
  52. * - `from`, `to` cannot be zero.
  53. * - `tokenId` token must be owned by `from`.
  54. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
  55. *
  56. * Emits a {Transfer} event.
  57. */
  58. function transferFrom(address from, address to, uint256 tokenId) external;
  59. /**
  60. * @dev Gives permission to `to` to transfer `tokenId` token to another account.
  61. * The approval is cleared when the token is transferred.
  62. *
  63. * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
  64. *
  65. * Requirements:
  66. *
  67. * - The caller must own the token or be an approved operator.
  68. * - `tokenId` must exist.
  69. *
  70. * Emits an {Approval} event.
  71. */
  72. function approve(address to, uint256 tokenId) external;
  73. /**
  74. * @dev Returns the account approved for `tokenId` token.
  75. *
  76. * Requirements:
  77. *
  78. * - `tokenId` must exist.
  79. */
  80. function getApproved(uint256 tokenId) external view returns (address operator);
  81. /**
  82. * @dev Approve or remove `operator` as an operator for the caller.
  83. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
  84. *
  85. * Requirements:
  86. *
  87. * - The `operator` cannot be the caller.
  88. *
  89. * Emits an {ApprovalForAll} event.
  90. */
  91. function setApprovalForAll(address operator, bool _approved) external;
  92. /**
  93. * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
  94. *
  95. * See {setApprovalForAll}
  96. */
  97. function isApprovedForAll(address owner, address operator) external view returns (bool);
  98. /**
  99. * @dev Safely transfers `tokenId` token from `from` to `to`.
  100. *
  101. * Requirements:
  102. *
  103. * - `from`, `to` cannot be zero.
  104. * - `tokenId` token must exist and be owned by `from`.
  105. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
  106. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
  107. *
  108. * Emits a {Transfer} event.
  109. */
  110. function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;
  111. }