错误hh8:在您的配置文件中有一个或多个错误: *无效的值nesthatconfig.networks.rinkeby.url-期望t的值
当我尝试在Rinkeby网络上运行脚本时,我会遇到此错误:
Error HH8: There's one or more errors in your config file:
Invalid value undefined for HardhatConfig.networks.rinkeby.url - Expected a value of type string.
require('@nomiclabs/hardhat-waffle');
require('dotenv').config();
module.exports = {
solidity: '0.8.1',
networks: {
rinkeby: {
url: process.env.STAGING_ALCHEMY_KEY,
accounts: process.env.PRIVATE_KEY,
},
},
};
.ENV文件
process.env.STAGING_ALCHEMY_KEY=https://eth-rinkeby.dotdotdot
process.env.PRIVATE_KEY=PRIVATE_KEY
,请有什么问题?
I get this error when i try to run my script on the rinkeby network:
Error HH8: There's one or more errors in your config file:
Invalid value undefined for HardhatConfig.networks.rinkeby.url - Expected a value of type string.
require('@nomiclabs/hardhat-waffle');
require('dotenv').config();
module.exports = {
solidity: '0.8.1',
networks: {
rinkeby: {
url: process.env.STAGING_ALCHEMY_KEY,
accounts: process.env.PRIVATE_KEY,
},
},
};
.env File
process.env.STAGING_ALCHEMY_KEY=https://eth-rinkeby.dotdotdot
process.env.PRIVATE_KEY=PRIVATE_KEY
Please what could possibly be the problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
检查您是否在根文件夹中,如果不在根文件夹中,请转到文件夹的根,然后重试
check are you in root folder or not, if not then go to root of folder and try again
在网络之后和URL之前添加Goerli。
Add goerli after networks and before url.
确保.env和hardhat.config.js都位于hardhat-tutorial文件夹中
make sure both .env and hardhat.config.js are in the hardhat-tutorial folder
可能是这里的几件事,但是如果您使用
create-react-app
您的.env
变量需要用react_app_app
将变量前缀。因此,以示例为例,您的Env变量staging_alchemy_key
应为react_app_staging_alchemy_key
。如果您使用webpack
,则可能需要在此处进行一些修改。希望这会有所帮助。Could be a few things here but if you're using
create-react-app
your.env
variables need to be prefixed withREACT_APP
. So by example your env variableSTAGING_ALCHEMY_KEY
should beREACT_APP_STAGING_ALCHEMY_KEY
. If you usewebpack
you might need to make some modifications in here as well. Hope this helps.