对这件事很陌生。试图在非技术领域为我的学士论文部署一个NFT。
我一直在遵循这个指南:https://www.freecodecamp.org/news/how-to-make-an-nft/,直到我应该部署NFT并编辑HardHat配置文件来编译所有内容之前,它一直进行得很顺利。
指南使用的是"ropsten“网络,而我使用的是rinkeby。这就是问题所在吗?
这是我的HardHat配置文件:
require("dotenv").config();
require("@nomiclabs/hardhat-ethers");
module.exports = {
solidity: "0.8.0",
defaultNetwork: "rinkeby",
networks: {
hardhat: {},
rinkeby: {
url: process.env.https://eth-rinkeby.alchemyapi.io/v2/MYURLCODE,
accounts: [`0x${process.env.MYPRIVATEKEY}`],
},
},
};
这是我的错误信息:
MYNAME@Ivans-MacBook-Pro ethereum % npx hardhat compile
An unexpected error occurred:
/Users/MYNAME/nft-project/ethereum/hardhat.config.js:10
url: process.env.https://eth-rinkeby.alchemyapi.io/v2/MYURL,
^
SyntaxError: Unexpected token ':'
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1033:15)
at Module._compile (node:internal/modules/cjs/loader:1069:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at importCsjOrEsModule (/Users/MYNAME/nft-project/ethereum/node_modules/hardhat/src/internal/core/config/config-loading.ts:28:20)
at loadConfigAndTasks (/Users/MYNAME/nft-project/ethereum/node_modules/hardhat/src/internal/core/config/config-loading.ts:80:18)
会非常感谢你的帮助!
发布于 2022-04-30 07:56:03
通过查看代码片段,我猜这行url: process.env.https://eth-rinkeby.alchemyapi.io/v2/MYURLCODE应该变成:
url: `https://eth-rinkeby.alchemyapi.io/v2/${process.env.MYURLCODE}`假设您的MYURLCODE env变量包含正确的值。
https://stackoverflow.com/questions/72061038
复制相似问题