source code:

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.9;

import "@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol";
import "hardhat/console.sol";

contract SampleToken is ERC20PresetMinterPauser{
    * constructor
    constructor(string memory name,string memory symbol) ERC20PresetMinterPauser(name,symbol) {}

subscan case:

  • When I paste the code below and try to verify, the following error occurs.
  • The error is :
Metadata file is not found. Did you include metadata.json?

blockscout case:

  • When I paste the code below and try to verify, the following error occurs.
  • The error is :
Compilation error: ["ParserError: Source \"@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol\" not found: File not found.
  • I think is because of the library, subscan verifier is not able to parse it. I have tried to delete the import and hardcoded all the code and I don't see that error anymore. (I see another: "Cannot read property 'length' of undefined"
    – Alex Bean
    Commented Nov 23, 2022 at 9:04
  • thanks for your reply. It is a little inconvenient to have to paste all the code of the inheritance destination. I wish there was another way. . . i will try too. Commented Nov 23, 2022 at 12:00

1 Answer 1


In order for Blockscout to verify your source code it requires that you upload the source of each smart contract you want to verify. That means all the source code used to generate binary. Note that this also includes contracts imported from OpenZeppelin. There are two ways to do it.

  1. Upload to Blockscout your contract and upload all imported OpenZeppelin contracts as individual files.
  2. Flatten the source code (merge all contracts in one file). You can do flattening with hardhat flatten command or include Remix Flattener plug-in and use Remix to flatten your files.

You might face some other challenges with flattened file. You first have to:

  • In the flattened file make sure there is only one license since each imported file will bring it's own license.
  • Make sure that the pragma solidity in the flattened file is actually the compiler version used to compile. Blockscout will ask you which compiler version was used.
  • Thank you Maario. I used the "hardhat flatten" command to output the code and have one license declaration. After that, I matched the compiler version and "verified", but the following error occurred. "No contract could be verified with provided data". Commented Nov 23, 2022 at 12:52
  • 1
    In your hardhat config file check which compiler version is used
    – Maario
    Commented Nov 23, 2022 at 13:14
  • Thank you so much ! Maario. I could solved this issue. v0.8.17 did not work, but v0.8.9 works ! Commented Nov 23, 2022 at 22:39

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.