ERC721 Transfer Issues – SafeTransferFrom Not Working While Transferring NFT to a Safe Address

contract-invocationgnosisgnosis-safenft

I was trying to transfer an NFT using ERC721's safeTransferFrom method from my gnosis safe to another gnosis safe address but while executing the transaction I am getting –

Error: cannot estimate gas; transaction may fail or may require manual gas limit (error={"code":3,"message":"execution reverted: GS013","data":"0x08c379a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000054753303133000000000000000000000000000000000000000000000000000000"}, method="estimateGas", transaction={"from":"0x3c7c3487d6782266059193C2593D6a2f9aC43989","to":"0x01d0a2c2fE8d8B08B3Df890cA5dBE4aBCE1Fa642","data":"0x6a7612020000000000000000000000009296c6130f9899c1f7b5798bceaf5356134135440000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001e0000000000000000000000000000000000000000000000000000000000000006442842e0e00000000000000000000000001d0a2c2fe8d8b08b3df890ca5dbe4abce1fa642000000000000000000000000b5f01e293a62b25e5e09c3c02e2e6fb2e2c4eca900000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000410000000000000000000000003c7c3487d6782266059193c2593d6a2f9ac4398900000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000","accessList":null}, code=UNPREDICTABLE_GAS_LIMIT, version=providers/5.5.3)
{
  reason: 'cannot estimate gas; transaction may fail or may require manual gas limit',
  code: 'UNPREDICTABLE_GAS_LIMIT',
  error: {
    code: 3,
    message: 'execution reverted: GS013',
    data: '0x08c379a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000054753303133000000000000000000000000000000000000000000000000000000'
  },
  method: 'estimateGas',
  transaction: {
    from: '0x3c7c3487d6782266059193C2593D6a2f9aC43989',
    to: '0x01d0a2c2fE8d8B08B3Df890cA5dBE4aBCE1Fa642',
    data: '0x6a7612020000000000000000000000009296c6130f9899c1f7b5798bceaf5356134135440000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001e0000000000000000000000000000000000000000000000000000000000000006442842e0e00000000000000000000000001d0a2c2fe8d8b08b3df890ca5dbe4abce1fa642000000000000000000000000b5f01e293a62b25e5e09c3c02e2e6fb2e2c4eca900000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000410000000000000000000000003c7c3487d6782266059193c2593d6a2f9ac4398900000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000',
    accessList: null
  }
}

On executing the same transaction with a different target address, i.e, my Metamask wallet address(EOA) it is working fine. Also when I tried transferring the NFT from my Metamask wallet to gnosis safe address via Opensea UI(Profile -> NFT -> Transfer) then also it is not working but working when the target address is my Metamask wallet address. So, I further checked and found Opensea UI also uses safeTransferFrom method to transfer NFTs.

Now, another thing I found is that transferring NFT to a safe address works fine with transferFrom method of ERC721.

So, not sure but I think the reason could be, as mentioned here:

If the target address is a contract, it must implement
IERC721Receiver.onERC721Received, which is called upon a safe
transfer, and return the magic value
bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"));
otherwise, the transfer is reverted.

This is the decoded data of the transaction which was failing.

  • Why safeTransferFrom is not working when target address is gnosis safe?
  • Is it fine to use transferFrom method as safeTransferFrom is not working?

Edit:
It is a bug in the gnosis SDK and an issue exist here for this. Once gnosis team fix this, I will mark this question as resolved.

Best Answer

A fallback handler that allows to handle NFTs is missing in the recipient Safe.

Fixed here how to add a fallback handler to a given Safe and adding a default fallback handler to newly deployed Safes: https://github.com/safe-global/safe-core-sdk/issues/262

Related Topic