1

In a local test environment, I am able to compile this implementation of the ERC721 token standard, deploy it, mint an NFT and transfer it (using the transferFrom function) to the following deployed vyper contract.

def transferFrom(_from: address, _to: address, _tokenId: uint256): nonpayable
    
@external
def transfer_out(_from: address, _to: address, _tokenId: uint256):
    Erc721(_from).transferFrom(_from, _to, _tokenId)

My goal is to transfer the NFT to a wallet from the contract by calling the transfer_out function above, but I get the following error when attempting that:

ContractLogicError: execution reverted: VM Exception while processing transaction: revert

EDIT:

SOLVED: I was passing the vyper contract's address to transfer_out as the _from address whereas I should have passed the ERC721 token standard contract's address.

1 Answer 1

1

If you did not already, you should first approve your contract from your EOA to give permission. Then you should be able to transfer the ERC721 token.

And transfer_out function should be:

def transfer_out(_from: address, _to: address, _tokenId: uint256):
   Erc721(contract_address).transferFrom(_from, _to, _tokenId)
6
  • 1
    Thanks (I fixed the function as you recocmmended). I tried both approve and setApprovalForAll on the contract address, and still I get the same error msg when I try transfer_out. Is it possible that when a wallet calls transfer_out the msg.sender is the wallet address and not the contract address? If so I would need to approve the original wallet before transferring it (but that is made impossible by the token standard, i.e. owners can't approve themselves)
    – Ryan
    Jun 25 at 20:46
  • Even though msg.sender is the external account, your contract still can't send t he token from your wallet directly without being approved(on the token implementation contract). But if the ERC721 token is already belong to your contract you should be able to send directly. Approval only necessary if a contract is required to send your tokens on your behalf
    – ofarukcaki
    Jun 25 at 21:16
  • yes when I run transfer_out the ERC721 token already belongs to the contract. That is why I am so confused about why it doesn't work
    – Ryan
    Jun 25 at 21:25
  • can you also try once with the safeTransferFrom instead
    – ofarukcaki
    Jun 25 at 21:38
  • safeTransferFrom also does not work
    – Ryan
    Jun 25 at 22:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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