我正在尝试使用npx硬帽子运行脚本/apply.js
omota@DESKTOP-3T9OR5N MINGW32 ~/web3-projects/tinder-blockchain/smart-contract (main)
$ npx hardhat run scripts/deploy.js --network goerli
Compiled 1 Solidity file successfully
error in depolying contract >> Error: could not detect network (event="noNetwork", code=NETWORK_ERROR, version=providers/5.7.2)
at Logger.makeError (C:\Users\omota\web3-projects\tinder-blockchain\smart-contract\node_modules\@ethersproject\logger\src.ts\index.ts:269:28)
at Logger.throwError (C:\Users\omota\web3-projects\tinder-blockchain\smart-contract\node_modules\@ethersproject\logger\src.ts\index.ts:281:20)
at EthersProviderWrapper.<anonymous> (C:\Users\omota\web3-projects\tinder-blockchain\smart-contract\node_modules\@ethersproject\providers\src.ts\json-rpc-provider.ts:483:23)
at step (C:\Users\omota\web3-projects\tinder-blockchain\smart-contract\node_modules\@ethersproject\providers\lib\json-rpc-provider.js:48:23)
at Object.throw (C:\Users\omota\web3-projects\tinder-blockchain\smart-contract\node_modules\@ethersproject\providers\lib\json-rpc-provider.js:29:53)
at rejected (C:\Users\omota\web3-projects\tinder-blockchain\smart-contract\node_modules\@ethersproject\providers\lib\json-rpc-provider.js:21:65)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
reason: 'could not detect network',
code: 'NETWORK_ERROR',
event: 'noNetwork'
}
//这是我的depoy.js文件
const { ethers } = require('hardhat')
const main = async () => {
const tinderFactory = await ethers.getContractFactory('TinderERC721')
const tinderContract = await tinderFactory.deploy()
console.log('TINDER CONTRACT ADDRESS:', tinderContract.address)
};
main()
.then(() => process.exit(0))
.catch(error => {
console.log('error in depolying contract >>', error);
process.exit(1);
})
//这是我的hardhat-config.js
require("@nomicfoundation/hardhat-toolbox");
require('dotenv').config({path: '.env'})
const ALCHEMY_API_URL = process.env.ALCHEMY_API_URL
const GOERLI_PRIVATE_KEY = process.env.GOERLI_PRIVATE_KEY
/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
defaultNetwork: 'goerli',
networks: {
goerli: {
url: ALCHEMY_API_URL,
accounts: [`0x${GOERLI_PRIVATE_KEY}`],
},
},
solidity: '0.8.17',
}
如有任何帮助,将不胜感激。
我已经做了我能做的一切,但仍然没有改变。
发布于 2022-10-28 23:26:48
也许你对ALCHEMY_API_URL有一些问题。它应以下列形式出现:
https://eth-goerli.alchemyapi.io/v2/${ALCHEMY_API_KEY}
或者可以肯定地说,您可以使用公共RPC节点:
https://goerli.infura.io/v3/ //default on metamask
https://rpc.ankr.com/eth_goerli //I tried and it worked
https://eth-goerli.public.blastapi.io
https://rpc.goerli.mudit.blog
https://stackoverflow.com/questions/74241276
复制相似问题