In ERC721 and ERC1155,
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?
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.Sign up to join this community
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.