Skip to content

nft.approve() Not works #3

@gurd33pS1ngh

Description

@gurd33pS1ngh

in _stake() function you used ERC721 approve function and , it gave error "ERC721: approve caller is not token owner nor approved for all".
Which is very obvious as for NFT contract msg.sender is Staking contract not the user and
see approve function of ERC721

function approve(address to, uint256 tokenId) public virtual override {
        address owner = ERC721.ownerOf(tokenId);
        require(to != owner, "ERC721: approval to current owner");

        require(
            _msgSender() == owner || isApprovedForAll(owner, _msgSender()),
            "ERC721: approve caller is not token owner nor approved for all"
        );

        _approve(to, tokenId);
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions