PatrickAlphaC / hardhat-smartcontract-lottery-fcc

MIT License
118 stars 181 forks source link

NomicLabsHardhatPluginError: Failed to send contract verification request. #172

Closed akashgreninja closed 1 year ago

akashgreninja commented 1 year ago

NomicLabsHardhatPluginError: Failed to send contract verification request. Endpoint URL: https://api-sepolia.etherscan.io/api Reason: The Etherscan API responded that the address 0xA7f1ACE8E6e0055ed85209846bc9267675eFFD75 does not have bytecode.

This comes when I run the yarn hardhat deploy --network sepolia

any ideas as to why ?

this is my hardhat config file

require("@nomiclabs/hardhat-waffle");
require("@nomiclabs/hardhat-etherscan");
require("hardhat-deploy");
require("solidity-coverage");
require("hardhat-gas-reporter");
require("hardhat-contract-sizer");
require("dotenv").config();

/** @type import('hardhat/config').HardhatUserConfig */

const SEPOLIA_RPC_URL = process.env.SEPOLIA_RPC_URL;
const PRIVATE_KEY = process.env.PRIVATE_KEY;
const ETHSCAN_API_KEY = process.env.ETHSCAN_API_KEY;
const COINMARKETCAP_API_KEY = process.env.COINMARKETCAP_API_KEY;

module.exports = {
  defaultNetwork: "hardhat",
  solidity: "0.8.19",
  namedAccounts: {
    deployer: {
      default: 0,
      1: 0,
    },
    player: {
      default: 1,
    },
  },
  networks: {
    hardhat: {
      chainId: 31337,
      blockconfirmations: 1,
    },
    sepolia: {
      url: SEPOLIA_RPC_URL,
      accounts: PRIVATE_KEY !== undefined ? [PRIVATE_KEY] : [],

      saveDeployments: true,
      chainId: 11155111,
    },
  },
  etherscan: {
    // yarn hardhat verify --network <NETWORK> <CONTRACT_ADDRESS> <CONSTRUCTOR_PARAMETERS>
    apiKey: {
        sepolia: ETHSCAN_API_KEY,

    },
  }, 

  gasReporter: {
    enabled: false,
    currency: "USD",
    outputFile: "gas-report.txt",
    noColors: true,
    // coinmarketcap: process.env.COINMARKETCAP_API_KEY,
  },
  mocha:{
    timeout: 400000
  }
};
21fahm commented 1 year ago

Show the code where you verify the code so as to push to etherscan ie: const { run } = require("hardhat");

const verify = async (contractAddress, args) => { console.log("Verifying..."); try { await run("verify:verify", { address: contractAddress, constructorArguments: args, }); } catch (e) { console.log(e); } };

module.exports = { verify, };

21fahm commented 1 year ago

Then where you deploy: if ( !mockOnThisNetworks.includes(network.name) && process.env.ETHERSCAN_API_KEY ) { await verify(raffle.address, args); log("\n------------------------"); } else { log("No deployment needed. LocalNetwork detected."); }

akashgreninja commented 1 year ago

@21fahm Thanks a lot it actually worked !!!!