You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Alchemy Goerli测试网时出现无效JSON RPC响应问题求助

问题:Hardhat部署到Goerli网络时遭遇Alchemy RPC的Cloudflare验证错误

我有一个一直连接Alchemy RPC端点的脚本,之前运行完全正常,但今天执行npx hardhat deploy --network goerli命令时,出现了如下错误。有人遇到过这个问题吗?

错误信息

Nothing to compile
failed to get chainId, falling back on net_version...
Error HH110: Invalid JSON-RPC response received: <!DOCTYPE html>
<html lang="en-US">
<head>
    <title>Just a moment...</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <meta name="robots" content="noindex,nofollow">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <link href="/cdn-cgi/styles/challenges.css" rel="stylesheet">
</head>

我的hardhat.config.js配置

require("@nomicfoundation/hardhat-toolbox")
require("@nomicfoundation/hardhat-chai-matchers")
require("@nomiclabs/hardhat-etherscan")
require("hardhat-deploy")
require("solidity-coverage")
require("hardhat-gas-reporter")
require("hardhat-contract-sizer")
require("dotenv").config()

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

const GOERLI_RPC_URL = process.env.GOERLI_RPC_URL
const PRIVATE_KEY = process.env.PRIVATE_KEY
const ETHERSCAN_API_KEY = process.env.ETHERSCAN_API_KEY
const COINMARKETCAP_API_KEY = process.env.COINMARKETCAP_API_KEY

module.exports = {
    defaultNetwork: "hardhat",
    networks: {
        localhost: {
            chainId: 31337,
        },
        hardhat: {
            chainId: 31337,
        },
        goerli: {
            blockConfirmations: 1,
            url: GOERLI_RPC_URL,
            accounts: [PRIVATE_KEY],
            chainId: 5,
        },
    },
    solidity: {
        compilers: [
            {
                version: "0.8.9",
            },
            {
                version: "0.8.0",
            },
        ],
    },
    namedAccounts: {
        deployer: {
            default: 0,
        },
        player: {
            default: 1,
        },
    },
}

解决建议

  • 错误根源是Cloudflare对Alchemy RPC请求触发了人机验证,返回的是验证页面而非合法JSON-RPC响应。
  • 先核对GOERLI_RPC_URL是否完整正确,确保没有遗漏Alchemy提供的密钥部分。
  • 切换网络环境(比如从公共WiFi换有线网络)或重启终端,避免被判定为异常流量。
  • 去Alchemy控制台重新生成Goerli网络的RPC端点,替换当前环境变量中的URL。
  • 等待一段时间再尝试,部分临时验证限制会自动解除。

内容的提问来源于stack exchange,提问作者Mei Kei

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.10 22:35:17