Search code examples
blockchainconfigsolidityweb3jshardhat

Error HH8: There's one or more errors in your config file: * Invalid value undefined for HardhatConfig.networks.rinkeby.url - Expected a value of t


I get this error when i try to run my script on the rinkeby network:

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

Invalid value undefined for HardhatConfig.networks.rinkeby.url - Expected a value of type string.
     require('@nomiclabs/hardhat-waffle');
require('dotenv').config();

module.exports = {
  solidity: '0.8.1',
  networks: {
    rinkeby: {
      url: process.env.STAGING_ALCHEMY_KEY,
      accounts: process.env.PRIVATE_KEY,
    },
   
  },
};

.env File

process.env.STAGING_ALCHEMY_KEY=https://eth-rinkeby.dotdotdot          
                                                                                 
process.env.PRIVATE_KEY=PRIVATE_KEY

Please what could possibly be the problem?


Solution

  • Could be a few things here but if you're using create-react-app your .env variables need to be prefixed with REACT_APP. So by example your env variable STAGING_ALCHEMY_KEY should be REACT_APP_STAGING_ALCHEMY_KEY. If you use webpack you might need to make some modifications in here as well. Hope this helps.