0

Getting an error while I'm trying to deploy a smart contract to Goerli testnet. The error:

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

* Invalid account: #0 for network: goerli - private key too long, expected 32 bytes

To learn more about Hardhat's configuration, please go to https://hardhat.org/config/

For more info go to https://hardhat.org/HH8 or run Hardhat with --show-stack-traces

Here is my hardhat.config.js file:

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

require("@nomiclabs/hardhat-waffle");

const ALCHEMY_API_KEY = "API_KEY";
const GOERLI_PRIVATE_KEY = "PRV_KEY";
module.exports = {
  solidity: "0.8.17",

  networks: {
    goerli: {
      url: `https://eth-goerli.alchemyapi.io/v2/${ALCHEMY_API_KEY}`,
      accounts: [GOERLI_PRIVATE_KEY],
    },
  },
};

I was on the same directory (The scripts directory). Also I copied the private key from Metamask of my Goerli account. I searched on google but found nothing helpful.

4
  • What is "PRV_KEY" here? I assume you are trying to import it from .env file. Is it so? Jan 17 at 15:12
  • Actually I hard typed api & key. & Before post just replaced with API_KEY & PRV_KEY. @SolidityLearner Jan 17 at 15:27
  • Make sure the private key is correct. And once without the strings. Jan 18 at 12:09
  • Or you can use .env file for it, that's how I always write code and it works every single time. Jan 18 at 12:09

1 Answer 1

0

After trying two days , I opened a new metamask and created a new account & by following the same private key copy method which I followed on my first metamask it worked perfectly, IDK what happend but it worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.