I'm trying to create a functionality where users can send their ERC721 tokens to my smart contract. I want to use the safeTransferFrom method, as it calls onERC721Received which ensures my system that the contract has received a token.

Now the first problem that I'm facing is that there's two types of ERC721 safeTransferFrom functions. The first one requires a data parameter, and the second one doesn't. Attempting to call this function from my frontend give this error: ContractMethodDoesNotExistError: Function "safeTransferFrom" on contract "0x932ca55b9ef0b3094e8fa82435b3b4c50d713043" does not exist.. But as you can see here on etherscan, this function exists twice as mentioned above.

Function in my frontend

        async transferERC721(contractAddress) {
            const config = await prepareWriteContract({
                address: this.formRaffle.tokenContract,
                abi: erc721ABI,
                functionName: 'safeTransferFrom',
                args: [


            const data = await writeContract(config);
            console.log("transferERC721 data", data)

The second problem which I'm facing is that some ERC721 contracts, such as Cryptopunks don't have a safeTransferFrom function. (https://etherscan.io/address/0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb#writeContract). This would be another reason why my function for transfering the NFT wouldn't work.

How would I implement a function where a user can transfer their ERC721 to my smart contract, and have the smart contract update it's state whenever this token gets received.

2 Answers 2


The ERC721 standard dictates that any implementing contract has to have both variants of the safeTransferFrom function. If a contract doesn't have those both, it simply isn't (fully) ERC721 compliant.

There are some ancient NFT contracts, such as Cryptopunks, which were created before the standard was finalized. Strictly speaking they don't follow the standard, but they are still considered as valid NFTs. I think third parties (various integrations) simply create exceptions for these few contracts.

Unfortunately I can't tell why your function isn't working. I guess your prepareWriteContract is from here but I've never heard of that library so I don't know how it works. If the contract includes the function then you should be able to call it. Maybe try with some other library, such as ethers.js ?

  • Thanks for ur comment, I'll just follow the path of approve and transferFrom in my contract then, no clue why the wagmi library isn't working. Might need to create a request on their github.
    – gggggggggg
    Commented Dec 30, 2022 at 2:30

I have found a solution that works for me. The ERC721 contract ABI contains two public functions called 'safeTransferFrom'. To fix the issue, you should remove one of these functions from the ERC721 ABI

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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