I code in my hardhat.config.js :

module.exports = {
  defaultNetwork: "hardhat",
  solidity: "0.8.24",
  networks: {
    sepolia: {
      url: "https://eth-sepolia.g.alchemy.com/v2/y4r3BgNFU-zhHGd8BWs-OhCMRR7ghpA2",
      accounts: [PRIVATE_KEY],
      chainId: 11155111,
    },
  }
};

And I run npx hardhat run scripts/deploy.js --network sepolia in the terminal,but there's an error says Invalid URL protocol: the URL must start with "http:"or "https:" Then I direct to where throw out the error, and print out the url

if (!/^https?:/.test(url.origin || url.protocol)) {
    console.log(url)
    throw new InvalidArgumentError('Invalid URL protocol: the URL must start with `http:` or `https:`.')
  }

This is the url printed out

URL {
  href: 'socks5://192.168.64.1:10808',
  origin: 'null',
  protocol: 'socks5:',
  username: '',
  password: '',
  host: '192.168.64.1:10808',
  hostname: '192.168.64.1',
  port: '10808',
  pathname: '',
  search: '',
  searchParams: URLSearchParams {},
  hash: ''
}

How can I resolve this error?

1

There are 1 best solutions below

0
Yilmaz On

i think the issue is here:

defaultNetwork: "hardhat"

it should be sepolia.

defaultNetwork: "sepolia"

also, make sure you import this:

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