Burning in ERC721 standard not working

I am trying to run the burn the token after I called awardItem to an address. It is not working for me. I am getting a revert error as shown:

await contract.burnToken(1)
Uncaught Error: Returned error: VM Exception while processing transaction: revert
at evalmachine.:1:18
at evalmachine.:2:49

I have checked that the token does exist:

await contract.ownerOf(1)
'0x52aA99B5423bC8Dfb9EB483649Dc100285463C25'

:1234: Code

> // SPDX-License-Identifier: MIT
> 
> pragma solidity >=0.6.0;
> 
> import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
> 
> import "@openzeppelin/contracts/utils/Counters.sol";
> 
> contract TradeAsset is ERC721URIStorage {
> 
>     using Counters for Counters.Counter;
> 
>     Counters.Counter private _tokenIds;
> 
>     mapping(string => uint8) hashes;
> 
>   constructor() ERC721("TradeContractToken", "TCT") {
> 
>   }
> 
> 
>   function awardItem(address recipient, string memory hash, string memory metadata)
> 
>   public
> 
>   returns (uint256)
> 
> {
> 
>   require(hashes[hash] != 1);
> 
>   hashes[hash] = 1;
> 
>   _tokenIds.increment();
> 
>   uint256 newItemId = _tokenIds.current();
> 
>   _mint(recipient, newItemId);
> 
>   _setTokenURI(newItemId, metadata);
> 
>   return newItemId;
> 
> }
> 
> function burnToken(uint256 tokenId) public {
> 
>   
> 
>   _burn(tokenId);
> 
>   
> 
> }
> 
> }

Built using
Truffle v5.3.8 (core: 5.3.8)
Solidity v0.5.16 (solc-js)
Node v14.16.1
Web3.js v1.3.6

EDIT:

Code i have ran:

truffle compile
truffle migrate
truffle console

contract = await TradeAsset.deployed()
await contract.setApprovalForAll("address_of_account2",true)
await contract.awardItem("account1","hash","uri")
await contract.ownerOf(1)
await contract.burnToken(1)

Hi @garysyndromes , welcome to Open Zeppelin!

After looking through the code, I would say update your compiler version. There may be something off about the 0.6.0 versions that you have. You will want to be on 0.8.0 along with the rest of the OZ contracts.

You should be able to upgrade them with your package manager that you use.

If that doesn’t work, then please link me the tutorial or contract you are following so I can compare exactly.

Thanks!

Hey @Yoshiko,
I am facing the same issue and I am running version 0.8.4.. Any fixes?