I have openzeppelin's standard ERC721
contract.
Below is the helper function that returns bytes data
that will be used for some purpose.
async function getErc721SafeTransferFromTransaction(tokenInstance, args) {
const txData = tokenInstance.interface.encodeFunctionData("safeTransferFrom",args);
return txData;
}
When I call that function with deployed ERC721
instance and [from,to,tokenId]
as an argument, I get the following error.
Error: multiple matching functions (argument="name", value="safeTransferFrom", code=INVALID_ARGUMENT, version=abi/5.6.4)
at Logger.makeError (node_modules/@ethersproject/logger/src.ts/index.ts:261:28)
at Logger.throwError (node_modules/@ethersproject/logger/src.ts/index.ts:273:20)
at Logger.throwArgumentError (node_modules/@ethersproject/logger/src.ts/index.ts:277:21)
at Interface.getFunction (node_modules/@ethersproject/abi/src.ts/interface.ts:210:24)
at Interface.encodeFunctionData (node_modules/@ethersproject/abi/src.ts/interface.ts:373:37)
at getErc721SafeTransferFromTransaction (test/utils/helper.js:30:44)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at runNextTicks (node:internal/process/task_queues:64:3)
at listOnTimeout (node:internal/timers:533:9)
at processTimers (node:internal/timers:507:7)
Seems like ethers.js is having issue is with safeTransferFrom
as openzeppelin's standard ERC721 has overloaded safeTransferFrom
method, one with data
argument and one without. How can I solve this and get the encoded data?