Solidity version error on Etherscan for verifing #5445
-
My solidity versions are 0.8.0 and 0.8.8 but on verifying the contract etherscan gives error reusing "BasicNFT" at 0x05342f309d4C1Fb467D33c8CE5478D8bd69880AB
Verifying...
Verifying contract...
NomicLabsHardhatPluginError: Etherscan only supports compiler versions 0.4.11 and higher.
See https://etherscan.io/solcversions for more information.
at SimpleTaskDefinition.action (/home/parthib/Web3/Etherum/NFTMarketplace/node_modules/@nomiclabs/hardhat-etherscan/src/index.ts:629:13)
at Environment._runTaskDefinition (/home/parthib/Web3/Etherum/NFTMarketplace/node_modules/hardhat/src/internal/core/runtime-environment.ts:330:35)
at Environment.run (/home/parthib/Web3/Etherum/NFTMarketplace/node_modules/hardhat/src/internal/core/runtime-environment.ts:163:25)
at /home/parthib/Web3/Etherum/NFTMarketplace/node_modules/hardhat/src/internal/core/runtime-environment.ts:289:29
at SimpleTaskDefinition.verifySubtask [as action] (/home/parthib/Web3/Etherum/NFTMarketplace/node_modules/@nomiclabs/hardhat-etherscan/src/index.ts:214:44)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at Environment._runTaskDefinition (/home/parthib/Web3/Etherum/NFTMarketplace/node_modules/hardhat/src/internal/core/runtime-environment.ts:330:14)
at Environment.run (/home/parthib/Web3/Etherum/NFTMarketplace/node_modules/hardhat/src/internal/core/runtime-environment.ts:163:14)
at verify (/home/parthib/Web3/Etherum/NFTMarketplace/utils/verify.js:6:9)
at Object.module.exports [as func] (/home/parthib/Web3/Etherum/NFTMarketplace/deploy/00-deploy-basicnft.js:31:9)
----------------------------------------------------
----------------------------------------------------
reusing "NFTMarketplace" at 0xc7f08eb7c4a6f829e6d508e946352317f2c5e49e
Verifying...
Verifying contract...
NomicLabsHardhatPluginError: Etherscan only supports compiler versions 0.4.11 and higher.
See https://etherscan.io/solcversions for more information.
at SimpleTaskDefinition.action (/home/parthib/Web3/Etherum/NFTMarketplace/node_modules/@nomiclabs/hardhat-etherscan/src/index.ts:629:13)
at Environment._runTaskDefinition (/home/parthib/Web3/Etherum/NFTMarketplace/node_modules/hardhat/src/internal/core/runtime-environment.ts:330:35)
at Environment.run (/home/parthib/Web3/Etherum/NFTMarketplace/node_modules/hardhat/src/internal/core/runtime-environment.ts:163:25)
at /home/parthib/Web3/Etherum/NFTMarketplace/node_modules/hardhat/src/internal/core/runtime-environment.ts:289:29
at SimpleTaskDefinition.verifySubtask [as action] (/home/parthib/Web3/Etherum/NFTMarketplace/node_modules/@nomiclabs/hardhat-etherscan/src/index.ts:214:44)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at Environment._runTaskDefinition (/home/parthib/Web3/Etherum/NFTMarketplace/node_modules/hardhat/src/internal/core/runtime-environment.ts:330:14)
at Environment.run (/home/parthib/Web3/Etherum/NFTMarketplace/node_modules/hardhat/src/internal/core/runtime-environment.ts:163:14)
at verify (/home/parthib/Web3/Etherum/NFTMarketplace/utils/verify.js:6:9)
at Object.module.exports [as func] (/home/parthib/Web3/Etherum/NFTMarketplace/deploy/01-deploy-nftmarketplace.js:24:9)
----------------------------------------------------
Done in 14.05s. hardhat.config file: require("@nomicfoundation/hardhat-toolbox");
require("@nomiclabs/hardhat-etherscan");
require("hardhat-deploy");
require("solidity-coverage");
require("hardhat-gas-reporter");
require("hardhat-contract-sizer");
require("dotenv").config();
const SEPOLIA_RPC_URL =
process.env.SEPOLIA_RPC_URL ||
"https://eth-sepolia.g.alchemy.com/v2/YOUR-API-KEY";
const POLYGON_MAINNET_RPC_URL =
process.env.POLYGON_MAINNET_RPC_URL ||
"https://polygon-mainnet.alchemyapi.io/v2/your-api-key";
const PRIVATE_KEY = process.env.PRIVATE_KEY || "0x";
// optional
const MNEMONIC = process.env.MNEMONIC || "your mnemonic";
// Your API key for Etherscan, obtain one at https://etherscan.io/
const ETHERSCAN_API_KEY =
process.env.ETHERSCAN_API_KEY || "Your etherscan API key";
const POLYGONSCAN_API_KEY =
process.env.POLYGONSCAN_API_KEY || "Your polygonscan API key";
const REPORT_GAS = process.env.REPORT_GAS || false;
/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
defaultNetwork: "hardhat",
solidity: {
compilers: [
{
version: "0.8.8",
},
{
version: "^0.8.0",
},
],
},
networks: {
hardhat: {
// // If you want to do some forking, uncomment this
// forking: {
// url: MAINNET_RPC_URL
// }
chainId: 31337,
},
localhost: {
chainId: 31337,
},
sepolia: {
url: SEPOLIA_RPC_URL,
accounts: PRIVATE_KEY !== undefined ? [PRIVATE_KEY] : [],
// accounts: {
// mnemonic: MNEMONIC,
// },
saveDeployments: true,
chainId: 11155111,
},
polygon: {
url: POLYGON_MAINNET_RPC_URL,
accounts: PRIVATE_KEY !== undefined ? [PRIVATE_KEY] : [],
saveDeployments: true,
chainId: 137,
},
},
etherscan: {
// npx hardhat verify --network <NETWORK> <CONTRACT_ADDRESS> <CONSTRUCTOR_PARAMETERS>
apiKey: {
sepolia: ETHERSCAN_API_KEY,
polygon: POLYGONSCAN_API_KEY,
},
},
gasReporter: {
enabled: REPORT_GAS,
currency: "USD",
outputFile: "gas-report.txt",
noColors: true,
// coinmarketcap: process.env.COINMARKETCAP_API_KEY,
},
contractSizer: {
runOnCompile: false,
only: ["NftMarketplace"],
},
namedAccounts: {
deployer: {
default: 0, // here this will by default take the first account as deployer
1: 0, // similarly on mainnet it will take the first account as deployer. Note though that depending on how hardhat network are configured, the account 0 on one network can be different than on another
},
player: {
default: 1,
},
},
mocha: {
timeout: 200000, // 200 seconds max for running tests
},
}; |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 10 replies
-
@Parthib314 Here everything looks correct, just you do not need these things if you are using hardhat toolbox plugins, maybe it is due to it. But you can leave repo if it does not work so I can see full code. + require("@nomicfoundation/hardhat-toolbox");
- require("@nomiclabs/hardhat-etherscan");
require("hardhat-deploy");
- require("solidity-coverage");
- require("hardhat-gas-reporter");
- require("hardhat-contract-sizer");
require("dotenv").config(); |
Beta Was this translation helpful? Give feedback.
-
Do you mind sharing which chains you deployed this on ? I tried checking the deployment addresses and they don't seem to be deployed to any chain |
Beta Was this translation helpful? Give feedback.
@Parthib314 The compiler version you were using was not supported for some dependencies. After changing it to
solidity: "0.8.17",
and updating the contracts version to^0.8.17
it is working fine and verifying the contracts.