Cannot verify contract deployed via Remix

pragma solidity ^0.5.0;

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.5.0/contracts/token/ERC20/ERC20.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.5.0/contracts/token/ERC20/ERC20Detailed.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.5.0/contracts/token/ERC20/ERC20Mintable.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.5.0/contracts/token/ERC20/ERC20Burnable.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.5.0/contracts/token/ERC20/ERC20Pausable.sol";

contract Cashback is ERC20, ERC20Detailed, ERC20Mintable, ERC20Burnable, ERC20Pausable  {

    constructor () public ERC20Detailed("Cashback", "CBK", 18) {
        _mint(msg.sender, 1000000 * (10 ** uint256(decimals())));
    }
}

Contract Address: https://etherscan.io/address/0x0a6EBca8c0Ae2C540d30BEC35BFA00CEAa7f7B3F

1 Like

Hello @Lifexcel,

You can use https://etherscan.io/verifyContract to start verifying your contract on etherscan.

Make sure you have flattened your contract i.e. all your contracts in a single file. In order to do that, you can use https://www.npmjs.com/package/truffle-flattener.

truffle-flattener <solidity-files>

Hope this solves your issue.

2 Likes

Thank you @sarang, I will do that and verify.

2 Likes

Hey, have you solved this problem?

1 Like

Hi @Lifexcel,

I verified the contract: https://etherscan.io/address/0x0a6EBca8c0Ae2C540d30BEC35BFA00CEAa7f7B3F#code

I used the following method with the Hardhat Etherscan plugin: Verify smart contract inheriting from OpenZeppelin Contracts

The contract bytecode ends with 511, which means it was compiled with Solidity 0.5.17

5110032

I converted the imports to npm imports and added an MIT License Identifier (though realized I made a typo in Identifier)

// SPDX-License-Identifer: MIT

pragma solidity ^0.5.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20Mintable.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20Burnable.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20Pausable.sol";

contract Cashback is ERC20, ERC20Detailed, ERC20Mintable, ERC20Burnable, ERC20Pausable  {

    constructor () public ERC20Detailed("Cashback", "CBK", 18) {
        _mint(msg.sender, 1000000 * (10 ** uint256(decimals())));
    }
}

I imported OpenZeppelin Contracts 2.5.0

npm install @openzeppelin/contracts@2.5.0

I could then use Hardhat Etherscan plugin to run verify:

$ npx hardhat verify --network mainnet 0x0a6EBca8c0Ae2C540d30BEC35BFA00CEAa7f7B3F
Downloading compiler 0.5.17
Compiling 13 files with 0.5.17
Compilation finished successfully
Successfully submitted source code for contract
contracts/Cashback.sol:Cashback at 0x0a6EBca8c0Ae2C540d30BEC35BFA00CEAa7f7B3F
for verification on etherscan. Waiting for verification result...
Successfully verified contract on etherscan
1 Like

Thanks @sarang and @Skyge :pray: for responding.

I verified the contract last week, but needed to write up how I did it.

@sarang, I recommend multi-file verification over flattening (where possible), as licenses and imports are maintained and it is much easier to read. I use the following method: Verify smart contract inheriting from OpenZeppelin Contracts

1 Like

Thank you very much @sarang and @abcoathup. I will practice with the next contract both ways and update you here.

1 Like

Thanks for the suggestion @abcoathup! I’ll definitely give it a shot in my next verification.

1 Like