我在我的
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,
},
}
};
我在终端中运行
npx hardhat run scripts/deploy.js --network sepolia
,但出现错误提示Invalid URL protocol: the URL must start with "http:"or "https:"
然后我指向抛出错误的地方,并打印出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:`.')
}
这是打印出来的
url
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: ''
}
如何解决此错误?
我认为问题出在这里:
defaultNetwork: "hardhat"
应该是
sepolia
。
defaultNetwork: "sepolia"
另外,请确保导入此:
require("@nomiclabs/hardhat-ethers");