Unexpected token u in JSON at position 0 when verify contracts

I'm trying to verify the contract on polygonscan(etherscan) using the truffle run verify command. What contract name do I use while trying to verify the contract we deployed above. The only contract I see is Migrations.sol which is not the minter contract.

Here's what I've tried so far:

$ truffle run verify ERC721PresetMinterPauserAutoId  --network mumbai
Verifying ERC721PresetMinterPauserAutoId
Unexpected token u in JSON at position 0
Failed to verify 1 contract(s): ERC721PresetMinterPauserAutoId

My node version is 14.15.1

I was able to deploy to both Goerli and Matic Mumbai testnet and see the NFT on opensea. Thanks again for the tutorial. Very nicely done.

1 Like

It seems like there is something wrong with your contract file, it has some illegal characters, I think you can format your contract to clear them, or just copy your code to another new file. I am not sure.

I think it might be something to do with my ERC721PresetMinterPauserAutoId.sol file .

This is the only content of the file I'm trying to verify.

import '@openzeppelin/contracts/token/ERC721/presets/ERC721PresetMinterPauserAutoId.sol';

Do I need to add any more logic before I try and verify this? My customization part is currently in migrations/2_deploy.js file

cat migrations/2_deploy.js 
// migrations/2_deploy.js
// SPDX-License-Identifier: MIT
const ERC721PresetMinterPauserAutoId = artifacts.require("ERC721PresetMinterPauserAutoId");

module.exports = function(deployer) {
  deployer.deploy(ERC721PresetMinterPauserAutoId, "Srv NFT","SRV", "https://my-json-server.typicode.com/ravsau/nft-metadata/tokens/");
};

And your contract has the constructor, so when you try to verify contracts, you should add these parameters.