Contract: https://etherscan.io/address/0xec16fed4f619aacd70c7db48327d362f675bfc29


// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.9.0;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract DogNFT is ERC721, Ownable {
    using Strings for uint256;
    mapping (uint256 => string) private _tokenURIs;
    mapping (uint256 => uint256) public tokenIdToPrice;

    string private _baseURIextended;

    constructor() ERC721("DogNFT", "DNFT") {}
    function setBaseURI(string memory baseURI_) external onlyOwner() {
        _baseURIextended = baseURI_;
    function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual {
        require(_exists(tokenId), "ERC721Metadata: URI set of nonexistent token");
        _tokenURIs[tokenId] = _tokenURI;
    function _baseURI() internal view virtual override returns (string memory) {
        return _baseURIextended;
    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");

        string memory _tokenURI = _tokenURIs[tokenId];
        string memory base = _baseURI();
        if (bytes(base).length == 0) {
            return _tokenURI;
        if (bytes(_tokenURI).length > 0) {
            return string(abi.encodePacked(base, _tokenURI));
        return string(abi.encodePacked(base, tokenId.toString()));
    function allowBuy(uint256 _tokenId, uint256 _price) external {
        require(msg.sender == ownerOf(_tokenId), 'Not owner of this token');
        require(_price > 0, 'Price zero');
        tokenIdToPrice[_tokenId] = _price;

    function disallowBuy(uint256 _tokenId) external {
        require(msg.sender == ownerOf(_tokenId), 'Not owner of this token');
        tokenIdToPrice[_tokenId] = 0;

    function mint(
        address _to,
        uint256 _tokenId,
        string memory tokenURI_
    ) external onlyOwner() {
        _mint(_to, _tokenId);
        _setTokenURI(_tokenId, tokenURI_);
        tokenIdToPrice[_tokenId] = 0;

    function buy(uint256 _tokenId) external payable {
        uint256 price = tokenIdToPrice[_tokenId];
        require(price > 0, 'This token is not for sale');
        require(msg.value == price, 'Incorrect value');
        address seller = ownerOf(_tokenId);
        safeTransferFrom(seller, msg.sender, _tokenId);
        tokenIdToPrice[_tokenId] = 0;

I tried using flatten and it removes duplicate licenses. I also changed the pragmas and kept only one in version 0.8.0. But he keeps making an error! (ps deploy by remix)

enter image description here


Trying hardhat. Output:

Error in plugin @nomiclabs/hardhat-etherscan: The address 0xec16fed4f619aacd70c7db48327d362f675bfc29 has no bytecode. Is the contract deployed to this network? The selected network is mainnet.



 * @type import('hardhat/config').HardhatUserConfig
const fs = require('fs');
const mnemonic = fs.readFileSync(".secret").toString().trim();
module.exports = {
  solidity: {
    version: "0.8.7",
    settings: {
      optimizer: {
        enabled: true,
        runs: 200
  networks: {
      mainnet: {
        url: `https://mainnet.infura.io/v3/xxx`,
        accounts: {mnemonic: mnemonic}
  etherscan: { apiKey: "xxx" }


Error in plugin @nomiclabs/hardhat-etherscan: The address provided as argument contains a contract, but its bytecode doesn't match any of your local contracts.

Possible causes are:
  - Contract code changed after the deployment was executed. This includes code for seemingly unrelated contracts.
  - A solidity file was added, moved, deleted or renamed after the deployment was executed. This includes files for seemingly unrelated contracts.
  - Solidity compiler settings were modified after the deployment was executed (like the optimizer, target EVM, etc.).
  - The given address is wrong.
  - The selected network (mainnet) is wrong.
  • try to create a new hardhat project, import your contracts and use the etherscan plugins, it will do it for you hardhat.org/plugins/nomiclabs-hardhat-etherscan.html
    – Majd TL
    Commented Nov 4, 2021 at 10:31
  • But my contract is deployed. I need deploy it again? @MajdTL
    – GIA
    Commented Nov 4, 2021 at 14:33
  • no you dont need to deploy it again, you will only compile and use the plugin to verify it
    – Majd TL
    Commented Nov 4, 2021 at 14:58
  • Invalid constructor arguments provided. Please verify that they are in ABI-encoded format
    – GIA
    Commented Nov 4, 2021 at 17:08
  • can you please post the command u used ? is it npx hardhat verify --network <your-network-name> 0xec16fed4f619aacd70c7db48327d362f675bfc29
    – Majd TL
    Commented Nov 4, 2021 at 18:03

2 Answers 2


Try this

Run npm init -y then npm install --save-dev hardhat after that open the folder in vsc and in the terminal run npx hradhat and choose Create an advanced sample project

Install Openzepplien $ npm install @openzeppelin/contracts

In hardhat.config.js add the configuration for mainnet and the config of solidity to 0.8.0 (the same compiler version u used to deploy)

Add your contract in ./contracts , change the compiler version and run npx hardhat compile

In etherscan sign in and create an api key and copy that api key to your hardhat.config.js

etherscan: { apiKey: "your-api-key" }

and then run npx hardhat verify --network mainnet 0xec16fed4f619aacd70c7db48327d362f675bfc29

If this is not working then try to copy all related Openzeppelin contracts u used from github main to your ./contracts and instead of import @OpenZe... use ./

  • Question edited. Look to output when I try hardhat.
    – GIA
    Commented Nov 6, 2021 at 17:46
  • Show me please the config of ur network in hardhat.config.js? @GuilhermeIA
    – Majd TL
    Commented Nov 6, 2021 at 17:52
  • question edited again. now I got another error
    – GIA
    Commented Nov 8, 2021 at 17:22
  • @GuilhermeIA have u tried to copy the openZeppelin contract (for the commit on the day you deploy it) and add them directly to ur project. because I have no more ideas and I can’t sadly try myself on the mainnet. Have you deployed the contract using the same way that day on a Test net first?
    – Majd TL
    Commented Nov 8, 2021 at 17:29
  • using hardhat works perfectly, old question but works!
    – GIA
    Commented Aug 18, 2022 at 20:34

Finally after 3 days - resolved

issue was with the compiler version!!. Hope it helps someone out...

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.