function approveBurn(address nft_cont_address,uint256 _tokenId) public {
  ERC721 tokenContract = ERC721(nft_cont_address);
  // approve the contract to burn the token
  tokenContract.approve(address(this), _tokenId);

Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending? Returned error: {"jsonrpc":"2.0","error":"execution reverted: ERC721: approve caller is not token owner or approved for all","id":8066513221942198}

Why am I getting this error and how to solve this?

  • Make sure to mark the answer if it helped✅ Commented Mar 20, 2023 at 5:43

1 Answer 1


The sender for this function in the NFT contract will be the contract through which you are calling the function. Is your contract owner of the tokens, if not then please share the contract. If no then you need to directly call the approve function from your wallet, not from another contract, coz the contract becomes msg.sender when calling another contract.

  • No my contract is not the owner of nft. is there anyway else approve function can be applied? Commented Mar 21, 2023 at 17:28
  • Nope You the user need to approve your contract either from etherscan or you can provide a UI for the user to approve it. The main thing is approve function should be called by the user with your contract address as the argument. Commented Mar 22, 2023 at 10:23

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.