Search code examples
nftvyper

Do I need to use approve method in ERC721?


I am practicing the smart contract and NFT looks interested to me.
ERC721 written in Vyper

What is the mechanic of approve in it?
What is isApprovedForAll does?

IMO. I don't need to use approve method. I just use transferFrom() is enough.
Correct me if I am wrong


Solution

  • The approval mechanism is described in more depth in the ERC-721 standard.

    What is the mechanic of approve in it?

    A token owner can approve another address (an operator) to spend a specific token using the approve() function, as well as all of the owner's tokens using setApprovalForAll().

    What is isApprovedForAll does?

    It's a getter function returning bool value whether an operator address can spend all of the owner tokens (i.e. they have been approved using the setApprovalForAll() function) - or not.

    I don't need to use approve method. I just use transferFrom() is enough.

    Correct if you're only spending your own tokens.

    If you want another address to spend your tokens, or if you want to spend tokens belonging to another owner (possibly one of your other addresses), you'll need to use the approval mechanism.