0

I'm following this Alchemy tutorial on how to deploy a smart contract on the Sepolia testnet. When I try to compile my smart contract, I get these errors:

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

  * Invalid value undefined for HardhatConfig.networks.sepolia.url - Expected a value of type string.
  * Invalid account: #0 for network: sepolia - private key too short, expected 32 bytes

Here is my hardhat.config.ts file

require("dotenv").config();
require("@nomiclabs/hardhat-ethers");

const { API_URL, PRIVATE_KEY } = process.env;

module.exports = {
  solidity: "0.7.3",
  defaultNetwork: "sepolia",
  networks: {
    hardhat: {},
    sepolia: {
      url: API_URL,
      accounts: [`0x${PRIVATE_KEY}`],
    },
  },
};

I've included my private key and the api_url in a .env file I'm not sure where the invalid errors are coming from

Han
  • 171
  • 2
  • 2
  • 7

1 Answers1

0

You need to change API_URL with your Sepolia RPC, you can do that by just hardcoding it like "https://xxx.xx/xxx" or just using an env variable ${API_URL}. Please make sure that your file is receiving the env variables correctly.

Josep Bové
  • 626
  • 1
  • 8
  • 22