How to populate bytes data argument of safeTransferFrom(address,address,uint256,bytes) of ERC721

I'm trying to create a front-end where a call to safeTransferFrom(address,address,uint256,bytes) happens for the univ3 staker contract (0xe34139463bA50bD61336E0c446Bd8C0867c6fE65). I need to populate the incentiveID value in the bytes argument, but its been throwing error. What is the way to populate this data ?


:computer: Environment

The data parameter is additional data, it has no specified format and it is sent in call to to, which in your case is the Uniswap V3 staker contract. To include the incentiveID value in the data parameter you will need to encode the value as a byte array using an encoder method. If you are using ethers.js it would look something like this:

const data = ethers.utils.defaultAbiCoder.encode(['uint256'], [incentiveID]);

// Call the safeTransferFrom function with the encoded data
await erc721.safeTransferFrom(senderAddress, univ3StakerAddress, tokenID, data);

It would be helpful to see your current implementation and the error its throwing, but since they were not provided I can only offer a general explanation, if you had exactly this set up and its not working please share te error you are getting.