all-on-chain-generated-nft icon indicating copy to clipboard operation
all-on-chain-generated-nft copied to clipboard

The updated config file wouldn't compile unless I changed the compiler to 8.1 and commented out the private keys.

Open mattjaf opened this issue 2 years ago • 4 comments

/**
 * @type import('hardhat/config').HardhatUserConfig
 */
require("@nomiclabs/hardhat-waffle")
require("@nomiclabs/hardhat-ethers")
require("@nomiclabs/hardhat-truffle5")
require("@nomiclabs/hardhat-etherscan")
require("hardhat-deploy")


require('dotenv').config()

const MAINNET_RPC_URL = process.env.MAINNET_RPC_URL || process.env.ALCHEMY_MAINNET_RPC_URL || "https://eth-mainnet.alchemyapi.io/v2/..........your key"
const RINKEBY_RPC_URL = process.env.RINKEBY_RPC_URL || "https://rinkeby.infura.io/v3/.....................your key"
const KOVAN_RPC_URL = process.env.KOVAN_RPC_URL || "https://kovan.infura.io/v3/......your key"
const MNEMONIC = process.env.MNEMONIC || "your mnemonic"
const ETHERSCAN_API_KEY = process.env.ETHERSCAN_API_KEY || "your api key"
// optional
const PRIVATE_KEY = process.env.PRIVATE_KEY || "your private key"

module.exports = {
    defaultNetwork: "hardhat",
    networks: {
        hardhat: {

            // // If you want to do some forking, uncomment this
            // forking: {
            //   url: MAINNET_RPC_URL
            // }
        },
        localhost: {
        },
        kovan: {
            url: KOVAN_RPC_URL,
            // accounts: [PRIVATE_KEY],
            accounts: {
                mnemonic: MNEMONIC,
            },
            saveDeployments: true,
        },
        rinkeby: {
            url: RINKEBY_RPC_URL,
            //  accounts: [PRIVATE_KEY],
            // accounts: {
            //  mnemonic: MNEMONIC,
            // },
            saveDeployments: true,
        },
        ganache: {
            url: 'http://localhost:8545',
            accounts: {
                mnemonic: MNEMONIC,
            }
        },
        mainnet: {
            url: MAINNET_RPC_URL,
            // accounts: [PRIVATE_KEY],
            accounts: {
                mnemonic: MNEMONIC,
            },
            saveDeployments: true,
        },
        polygon: {
            url: "https://rpc-mainnet.maticvigil.com/",
            // accounts: [PRIVATE_KEY],
            accounts: {
                mnemonic: MNEMONIC,
            },
            saveDeployments: true,
        },
    },
    etherscan: {
        // Your API key for Etherscan
        // Obtain one at https://etherscan.io/
        apiKey: ETHERSCAN_API_KEY
    },
    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
        },
        feeCollector: {
            default: 1
        }

    },
    solidity: {
        compilers: [
            {
                version: "0.8.1"
            },
            {
                version: "0.7.0"
            },
            {
                version: "0.6.6"
            },
            {
                version: "0.4.24"
            }
        ]
    },
    mocha: {
        timeout: 100000
    }
}

mattjaf avatar Mar 12 '22 06:03 mattjaf

Could you make this in a pull request? 🙏

PatrickAlphaC avatar Mar 14 '22 21:03 PatrickAlphaC

Ended up having to do it manually...

It'd be cool to see how the "pull request" is done the OG gangster way

mattjaf avatar Mar 15 '22 07:03 mattjaf

I'll leave this issue open if anyone else ran into it

PatrickAlphaC avatar Mar 19 '22 03:03 PatrickAlphaC

Still trying to understand it as well, I though I broke my hardhat for like 10 straight hours.

Hope this helps,

Seems like when the .env file doesn't have the value for private key it throws:

Error HH8: There's one or more errors in your config file:

  * Invalid account: #0 for network: kovan - private key too short, expected 32 bytes
  * Invalid account: #0 for network: rinkeby - private key too short, expected 32 bytes
  * Invalid account: #0 for network: ganache - private key too short, expected 32 bytes
  * Invalid account: #0 for network: mainnet - private key too short, expected 32 bytes
  * Invalid account: #0 for network: polygon - private key too short, expected 32 bytes

After, commenting it out and trying to compile with 8.4 it throws:

Internal exception in StandardCompiler::compile: C:\Users\circleci\project\libsolidity\ast\AST.cpp(183): Throw in function class std::vector<class solidity::frontend::ErrorDefinition const *,class std::allocator<class solidity::frontend::ErrorDefinition const *> > __cdecl solidity::frontend::ContractDefinition::interfaceErrors(bool) const
Dynamic exception type: struct boost::wrapexcept<struct solidity::langutil::InternalCompilerError>
std::exception::what: 
[struct solidity::util::tag_comment * __ptr64] = 

Error HH600: Compilation failed

Trying to compile with 8.0 it throw:

Error HH606: The project cannot be compiled, see reasons below.


The Solidity version pragma statement in these files doesn't match any of the configured compilers in your config. Change the pragma or configure additional compiler versions in your hardhat config.

  * @openzeppelin/contracts/utils/Address.sol (^0.8.1)


These files and its dependencies cannot be compiled with your config. This can happen because they have incompatible Solidity pragmas, or don't match any of your configured Solidity compilers.


  * contracts/RandomSVG.sol
  * contracts/SVGNFT.sol
  * @openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol
  * @openzeppelin/contracts/token/ERC721/ERC721.sol

To learn more, run the command again with --verbose

Read about compiler configuration at https://hardhat.org/config

mattjaf avatar Mar 19 '22 04:03 mattjaf