Config or metamask UNKNOWN account to fix?

Hi everybody, I’m new with MetaMask i’m trying to do this tutorial

but it gives me error non the config file

require(‘dotenv’).config();
const PRIVATE_KEY = process.env.PRIVATE_KEY;

require(“@nomicfoundation/hardhat-toolbox”);

/** @type import(‘hardhat/config’).HardhatUserConfig */
module.exports = {
defaultNetwork: “matic”,
networks: {
hardhat: {
},
matic: {
url: “https://rpc-mumbai.maticvigil.com”,
accounts: [PRIVATE_KEY]
}
},
solidity: {
version: “0.8.0”,
settings: {
optimizer: {
enabled: true,
runs: 200
}
}
},
paths: {
sources: “./contracts”,
tests: “./test”,
cache: “./cache”,
artifacts: “./artifacts”
},
mocha: {
timeout: 20000
}
}

it says
Error HH8: There’s one or more errors in your config file:

  • Invalid account: #0 for network: matic - Expected string, received undefined

i don’t know if it’s a problem of the config file or the problem is the account of MetaMask it tells me UNKNOWN

Coud you help me to understand which thing to fix??
thank you for help

Hello @surferbloggy !
Welcome to MetaMask community !

Make sure you created the .env file correctly and it looks like this and is in the current directory with your package.json as in the screenshot:

In order to better understand this, can you upload the source code to github?

1 Like

thank you for the answer maybe the problem could be the quotation marks i’ve deleted them
or you could understand if the .env and .gitignore are not in the root??

if I digit ls -a I get this tree

. README.md package-lock.json
… contracts package.json
.env hardhat.config.js scripts
.gitignore node_modules test

and it tells me now another thing that

WARNING: You are using a version of Node.js that is not supported, and it may work incorrectly, or not work at all. See hardhat. org/ nodejs-versions

Error HH601: Script scripts/sample-script.js doesn’t exist.

infact in the tutorial says

You should have a directory that looks like this:

contracts
-Greeter.sol
scripts
-sample-script.js
test
-sample-test.js
.gitignore
hardhat.config.js
package-lock.json
package.json

but in script folder there is only deploy.js

may I have to add a sample-script.js
just for testing??
thank you for help

scripts % npx hardhat run scripts/sample-script.js --network matic

WARNING: You are using a version of Node.js that is not supported, and it may work incorrectly, or not work at all. See https hardhat. org/ nodejs-versions

Error HH8: There’s one or more errors in your config file:

  • Invalid account: #0 for network: matic - Expected string, received undefined

To learn more about Hardhat’s configuration, please go to https: hardhat. org/ config/

For more info go to https hardhat. org/ HH8 or run Hardhat with --show-stack-traces

what’s the problem how do you suggest to fix it

I’ll upload to github thank you

@surferbloggy

You probably need to check your current version of Node.js.
Node Version Manager (NVM) allows you to simultaneously install and maintain many different independent versions of Node.js and their associated Node packages.

If you use a MAC OS, you can manually try the various versions of Node.
The installation process is as follows:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash

source ~/.bashrc

nvm install v16.10.0

:boom: You can also check which versions of Node are available:

nvm list-remote

2 Likes

This topic was automatically closed after 30 days. New replies are no longer allowed.