Unable to verify the contract on polygonscan

I’m trying to verify my contract on mumbai.polygonscan.com. The verification doesn’t go through, because I’m getting parse errors on my imports. It’s a standard ERC-1155 contract. Here’s the error I’m getting from polygonscan:

Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: " to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.
--> myc

ParserError: Source "@openzeppelin/contracts/token/ERC1155/ERC1155.sol" not found: File import callback not supported
 --> myc:3:1:
  |
3 | import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

ParserError: Source "@openzeppelin/contracts/access/Ownable.sol" not found: File import callback not supported
 --> myc:4:1:
  |
4 | import "@openzeppelin/contracts/access/Ownable.sol"
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

How do I import openzeppelin contract without these errors?

You’ll have to include the source for those imports

But do I still put the imports in the contract code?

No, you remove the imports after you include their sources.

1 Like

It may be easier to start from an already validated contract and copy from there most of its source.

This may help you too: https://www.youtube.com/watch?v=dvvaBq6d_dE&ab_channel=MoralisWeb3

@ApesTogetherStrong flattening the contract with Remix should get rid of those errors.