yarn hardhat error #2351
-
Done in 3.13s.
etobillion@DESKTOP-BSPAU6M:~/hardhat-simple-storage-fcc$ yarn hardhat
yarn run v1.22.19
$ /home/etobillion/hardhat-simple-storage-fcc/node_modules/.bin/hardhat
An unexpected error occurred:
/home/etobillion/hardhat-simple-storage-fcc/hardhat.config.js:31
solidity: "0.8.9",
^^^^^^^^
SyntaxError: Unexpected identifier
at Object.compileFunction (node:vm:360:18)
at wrapSafe (node:internal/modules/cjs/loader:1055:15)
at Module._compile (node:internal/modules/cjs/loader:1090:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
at Module.load (node:internal/modules/cjs/loader:1004:32)
at Function.Module._load (node:internal/modules/cjs/loader:839:12)
at Module.require (node:internal/modules/cjs/loader:1028:19)
at require (node:internal/modules/cjs/helpers:102:18)
at importCsjOrEsModule (/home/etobillion/hardhat-simple-storage-fcc/node_modules/hardhat/src/internal/core/config/config-loading.ts:28:20)
at loadConfigAndTasks (/home/etobillion/hardhat-simple-storage-fcc/node_modules/hardhat/src/internal/core/config/config-loading.ts:80:18)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
etobillion@DESKTOP-BSPAU6M:~/hardhat-simple-storage-fcc$```
having this problem with hardhat, any help would be appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 6 replies
-
Hey @bitestera please share your |
Beta Was this translation helpful? Give feedback.
-
const {task} = require("hardhat/config");
require("dotenv").config()
/** @type import('hardhat/config').HardhatUserConfig */
const RINKEBY_RPC_URL = process.env.RINKEBY_RPC_URL
const PRIVATE_KEY = process.env.PRIVATE_KEY
module.exports = {
defaultNetwork: "hardhat",
networks:{
rinkeby:{
url: RINKEBY_RPC_URL,
accounts: [PRIVATE_KEY],
chainId: 4,
},
}
solidity: "0.8.9",
};
};
|
Beta Was this translation helpful? Give feedback.
-
@bitestera remove the extra About |
Beta Was this translation helpful? Give feedback.
-
Solution for Windows 11 + WSL2 + HardHat v2.11.2 deploy.jsconst { ethers } = require("hardhat")
const fs = require("fs-extra")
require("dotenv").config()
async function main() {
const factory = await ethers.getContractFactory("SimpleStorage")
console.log("Deploying Contract...")
const SimpleStorage = await factory.deploy()
await SimpleStorage.deployed()
}
main()
.then(() => {
console.log("Closing")
process.exit(0)
})
.catch((error) => {
console.log("Error Encountered:")
console.error(error)
process.exit(1)
}) hardhat.config.jsrequire("@nomicfoundation/hardhat-toolbox")
require("@nomiclabs/hardhat-ethers")
require("dotenv").config()
/** @type import('hardhat/config').HardhatUserConfig */
const RPC_URL = process.env.RPC_URL
const PRIVATE_KEY = process.env.PRIVATE_KEY
module.exports = {
defaultNetwork: "hardhat",
networks: {
goerli: {
url: RPC_URL,
accounts: [PRIVATE_KEY],
chainId: 5,
},
},
solidity: "0.8.9",
}
task("accounts", "Prints the list of accounts", async () => {
const accounts = await ethers.getSigners()
for (const account of accounts) {
console.log(account.address)
}
}) notice in the hardhat.config.js, I'm using process.env variables. If you followed lesson 5, you should be able to copy/paste your .env file from lesson 5 to this directory and you're good to go! |
Beta Was this translation helpful? Give feedback.
Hey @bitestera please share your
hardhat.config.js
file