Bugs verifying Open Zepplin ERC20 Contracts on Etherscan

I'm working on verifying an Open Zepplin ERC20 Contract on Etherscan. The code compiles fine in remix with the exception of the following error:

You have not set a script to run. Set it with @custom:dev-run-script NatSpec tag

This is a consistent bug that pops up and the solution in the docs says to run:


to fix it. But a more general problem is that the bug is not well documented nor are the requirements for a script to run in the documentation.

That said, once the bug is fixed with the keyboard shortcut, the code runs perfect and I was able to deploy the ERC20 contract to the MainNet as follows:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract ChoiceCoin is ERC20 {
    constructor() ERC20("Choice Coin", "Choice") {
        _mint(msg.sender, 1000000000000000000000000000);

The contract launched as intended:


However, I am struggling to verify the contract on Etherscan. I read this post, however I used Remix and not HardHat or Truffle. Specifically, I used the Remix 0.8.7+commit.e28d00a7 compiler.

Probably the main bug in the process is Etherscan fails to verify the contract and returns the recomendation:

For troubleshooting, you can try compiling your source code with the [Remix - Solidity IDE](https://remix.ethereum.org/) and check for exceptions

However, my script does compile in Remix and it was verified. But, there is no guidance on how to find exceptions. I tried various other strategies to verify the code including: using the GitHub Gist, using the multi-file option, and verifying using the entire Open Zepplin ERC20 contract. However, Etherscan failed to verify each method. I created a folder on GitHub with screenshots of each failed verification and response from Etherscan.

Moving forward, my goal is to verify and open source the contract. I would sincerely appreciate any advice or guidance on how to proceed. Hopefully, this post will help to debug the problem and make it easier to verify Open Zepplin ERC20 contracts in the future. Thanks in advance.

Hi, have you checked this tutorial?

1 Like