ERC721Receiver.sol 1.2 KB

123456789101112131415161718192021222324252627282930
  1. pragma solidity ^0.4.21;
  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,uint256,bytes)"))`,
  11. * which can be also obtained as `ERC721Receiver(0).onERC721Received.selector`
  12. */
  13. bytes4 constant ERC721_RECEIVED = 0xf0b9e5ba;
  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. This function MUST use 50,000 gas or less. Return of other
  19. * than the magic value MUST result in the transaction being reverted.
  20. * Note: the contract address is always the message sender.
  21. * @param _from The sending address
  22. * @param _tokenId The NFT identifier which is being transfered
  23. * @param _data Additional data with no specified format
  24. * @return `bytes4(keccak256("onERC721Received(address,uint256,bytes)"))`
  25. */
  26. function onERC721Received(address _from, uint256 _tokenId, bytes _data) public returns(bytes4);
  27. }