ERC721Receiver.sol 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. pragma solidity ^0.4.24;
  2. /**
  3. * @title ERC721 token receiver interface
  4. * @dev Interface for any contract that wants to support safeTransfers
  5. * from ERC721 asset contracts.
  6. */
  7. contract ERC721Receiver {
  8. /**
  9. * @dev Magic value to be returned upon successful reception of an NFT
  10. * Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`,
  11. * which can be also obtained as `ERC721Receiver(0).onERC721Received.selector`
  12. */
  13. bytes4 internal constant ERC721_RECEIVED = 0x150b7a02;
  14. /**
  15. * @notice Handle the receipt of an NFT
  16. * @dev The ERC721 smart contract calls this function on the recipient
  17. * after a `safetransfer`. This function MAY throw to revert and reject the
  18. * transfer. Return of other than the magic value MUST result in the
  19. * transaction being reverted.
  20. * Note: the contract address is always the message sender.
  21. * @param _operator The address which called `safeTransferFrom` function
  22. * @param _from The address which previously owned the token
  23. * @param _tokenId The NFT identifier which is being transferred
  24. * @param _data Additional data with no specified format
  25. * @return `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`
  26. */
  27. function onERC721Received(
  28. address _operator,
  29. address _from,
  30. uint256 _tokenId,
  31. bytes _data
  32. )
  33. public
  34. returns(bytes4);
  35. }