2

I deployed an ERC-20 Token contract and would like to now verify it on etherscan.io

My contract utilizes Open-Zeppelin's library of contracts - which means it's importing one of their contracts into itself, like so:

pragma solidity ^0.5.0;

import "../node_modules/openzeppelin-solidity/contracts/token/ERC20/ERC20.sol";


contract MyTestCoin is ERC20 {

   // etc.

Of course, it so happens that this imported ERC20.sol contract imports other contracts into itself as well, so the rabbit hole gets even deeper.

So my question is basically this: if I want to verify my contract, can I just verify IT, or do I need to also somehow verify every other contract it imports as well?

Also, what Open Source License Type should I choose when I go through the verification process? etherscan.io has like 9 different options you can choose from - and I can't tell what's right for this.

Any help would be greatly appreciated.


UPDATE

ok, I tried using truffle flattened in Terminal. It combined and outputted the code of all the files I pointed it to into one stream, so I copy-pasted that code into the etherscan verification page and got this error:

Compiler debug log:
 Error! Unable to generate Contract ByteCode and ABI
 Found the following ContractName(s) in source code : ERC20, IERC20, MyTestCoin, SafeMath
 But we were unable to locate a matching bytecode (err_code_2)
 For troubleshooting, you can try compiling your source code with the Remix - Solidity IDE and check for exceptions

So - what's that all about?


UPDATE # 2

As per the suggestion in the error message I received, I took all the code and compiled it in Remix - there were no errors. So the code seems to be just fine...

4

You have basically three options.

1. Truffle-flattener

You can use truffle-flattener to create a file that contains all the imported contract's source codes. The result can be used to easily verify a contract on Etherscan.

2. truffle-plugin-verify

You may also try truffle-plugin-verify if you are using Truffle. You'll need an API key from Etherscan for this.

3. Etherscan with multiple files

Or you can choose Etherscan verification with multiple files and add every single file individually. (not recommended)

Also, what Open Source License Type should I choose when I go through the verification process? etherscan.io has like 9 different options you can choose from - and I can't tell what's right for this.

If you don't know yet, choose 'None', if you don't really care pick 'Unlicensed' or 'MIT'. If you want something specific, look up each license's definition.

3
  • ok, I tried option 1 - and got an error. Please see my updated question for the specifics. (And thanks!)
    – Mark55
    May 19 '20 at 3:03
  • @Sirab33 Please open up new separate questions for that. May 19 '20 at 3:27
  • Just got it working. Needed to select "YES" in the "OPTIMIZATION" drop menu choice when doing the verification. Will mark yours as the right answer :-)
    – Mark55
    May 19 '20 at 3:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.