In ERC721 and ERC1155, 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?
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.
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?
Jul 22, 2019 at 16:42
onERC721Received
is to do nothing and this is how they have implemented it.
Jul 23, 2019 at 14:57