PatrickAlphaC / all-on-chain-generated-nft

A repo for generating random NFTs with metadata 100% on chain!
MIT License
356 stars 150 forks source link

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

Open mattjaf opened 2 years ago

mattjaf commented 2 years ago
/**
 * @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
    }
}
PatrickAlphaC commented 2 years ago

Could you make this in a pull request? 🙏

mattjaf commented 2 years ago

Ended up having to do it manually...

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

PatrickAlphaC commented 2 years ago

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

mattjaf commented 2 years ago

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