gpt4 book ai didi

node.js - 错误 HH604 : Error running JSON-RPC server: Must be authenticated! Hardhat Node.js Alchemy

转载 作者:行者123 更新时间:2023-12-05 03:30:20 26 4
gpt4 key购买 nike

我在 VScode 中使用所需的依赖项设置了 Hardhat,并使用 Metamask 运行了一个 Alchemy Node 。我已经尝试了我在网上找到的大部分故障排除并阅读了大部分文档,但我仍然迷路了。无论您需要什么信息,我都可以提供。什么都有帮助。太感谢了。我对此很陌生,所以请和我一起工作。

这是我收到的错误:

npx hardhat node
Error HH604: Error running JSON-RPC server: Must be authenticated!

Hardhat.config.ts

import "@typechain/hardhat";
import "@nomiclabs/hardhat-ethers";
import "@nomiclabs/hardhat-waffle";
import "@nomiclabs/hardhat-etherscan";
import "hardhat-gas-reporter";
import "solidity-coverage";
import "@openzeppelin/hardhat-upgrades";

import "hardhat-deploy";

import { resolve } from "path";

import { config as dotenvConfig } from "dotenv";
import { HardhatUserConfig } from "hardhat/config";
import { NetworkUserConfig } from "hardhat/types";

dotenvConfig({ path: resolve(__dirname, "./.env") });

const chainIds = {
goerli: 5,
hardhat: 1337,
kovan: 42,
mainnet: 1,
rinkeby: 4,
ropsten: 3,
};

// Ensure that we have all the environment variables we need.
const privateKey = process.env.PRIVATE_KEY;
// Make sure node is setup on Alchemy website
const alchemyApiKey = process.env.ALCHEMY_API_KEY;

function getChainConfig(network: keyof typeof chainIds): NetworkUserConfig {
const url = `https://eth-${network}.alchemyapi.io/v2/${alchemyApiKey}`;
return {
accounts: [`${privateKey}`],
chainId: chainIds[network],
url,
};
}

const config: HardhatUserConfig = {
defaultNetwork: "hardhat",
gasReporter: {
currency: "USD",
enabled: process.env.REPORT_GAS ? true : false,
excludeContracts: [],
src: "./contracts",
},
networks: {
hardhat: {
forking: {
url: `https://eth-mainnet.alchemyapi.io/v2/${alchemyApiKey}`,
},
chainId: chainIds.hardhat,
},
// Uncomment for testing. Commented due to CI issues
// mainnet: getChainConfig("mainnet"),
// rinkeby: getChainConfig("rinkeby"),
// ropsten: getChainConfig("ropsten"),
},
paths: {
artifacts: "./artifacts",
cache: "./cache",
sources: "./contracts",
tests: "./test",
deploy: "./scripts/deploy",
deployments: "./deployments",
},
solidity: {
compilers: [
{
version: "0.8.10",
settings: {
metadata: {
bytecodeHash: "none",
},
optimizer: {
enabled: true,
runs: 800,
},
},
},
{
version: "0.8.10",
settings: {
metadata: {
bytecodeHash: "none",
},
optimizer: {
enabled: true,
runs: 800,
},
},
},
{
version: "0.7.5",
settings: {
metadata: {
bytecodeHash: "none",
},
optimizer: {
enabled: true,
runs: 800,
},
},
},
{
version: "0.5.16",
},
{
version: "0.8.10",
settings: {
metadata: {
bytecodeHash: "none",
},
optimizer: {
enabled: true,
runs: 800,
},
},
},
],
settings: {
outputSelection: {
"*": {
"*": ["storageLayout"],
},
},
},
},
namedAccounts: {
deployer: {
default: 0,
},
daoMultisig: {
// mainnet
1: "HIDDEN",
},
},
typechain: {
outDir: "types",
target: "ethers-v5",
},
etherscan: {
apiKey: process.env.ETHERSCAN_API_KEY,
},
mocha: {
timeout: 1000000,
},
};

export default config;

最佳答案

当 Alchemy URL 不正确时,通常会显示此错误。如果有帮助,您可以尝试验证一次 key 。

关于node.js - 错误 HH604 : Error running JSON-RPC server: Must be authenticated! Hardhat Node.js Alchemy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70826940/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com