According to ERC-721 interface the function safeTransferFrom seems to be overloaded:

function safeTransferFrom(address _from, address _to, uint256 _tokenId) public;
function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes _data) public;

Why so? Any ideas? Thx!

2 Answers 2


The one without _data doesn't send any data when it calls the other contract. (It sends a zero-length byte sequence.)

The one with _data does.

  • This is incorrect, the other contract must implement the wallet interface, which has the 3-parameter function onERC721Received(address _from, uint256 _tokenId, bytes data). If you only pass two, the transaction will fail. Commented Apr 17, 2018 at 2:39
  • I'm not sure what part of my answer you think is "incorrect." Could you explain further? Perhaps there's something that could be clarified. (To be clear, I agree with the rest of your comment.)
    – user19510
    Commented Apr 17, 2018 at 3:05
  • "The one without _data doesn't send any data when it calls the other contract." - technically it should still pass data when it calls the other function, the data is just an empty string (see my answer below). Commented Apr 17, 2018 at 3:08
  • Ah, I'll clarify.
    – user19510
    Commented Apr 17, 2018 at 3:11

From the ERC-721 draft standard, take note of the code comments in the interface provided.

Specifically, for the safeTransferFrom function without the 4th parameter:

/// @dev This works identically to the other function with an extra data parameter,
///  except this function just sets data to ""

So your three-parameter function should do exactly the same as the four-parameter function, but pass "" as the data.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.