1

In ERC721, safeTransferFrom has bytes data parameter.

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

how do I send data (is it in hex format?) and what does it do?

1

Considering you are interfacing with an existing contract (i.e. calling it).

You can send any data you want, such as a string converted to bytes. Here is just one example I have lying around on how to wrangle strings and bytes https://github.com/su-squares/ethereum-contract/blob/master/contracts/SuNFT.sol#L221-L239

The reason why you would do this is application-specific. In other words, only send data if the specific ERC-721 contract you are sending to tells you to, and follow any prescriptions they give you. The myriad ways that applications could describe how you would use these bytes could not be predicted in 2018 (when ERC-721 finalized) and no value existed in cataloging and standardizing these use cases ahead of time.

  • Thanks for your answer, but when looking at the openzeppelin's solution , data param is passed to the onERC721Received which does nothing essentially. All the values passed to that function technically do nothing but it only gets the function signature. Am I understanding this correctly? – bbusdriver Jul 22 at 16:42
  • That is correct. OpenZeppelin and 0xcert maintain reference implementations. That means they should have the minimal acceptable feature set. The minimal acceptable feature for onERC721Received is to do nothing and this is how they have implemented it. – William Entriken Jul 23 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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