When ever I run
npx hardhat run scripts/deploy.js --network mumbai
Error HH8: There's one or more errors in your config file:
Invalid account: #0 for network: mumbai - Expected string, received undefined
I have no clue what to do to fix this I have been at this for like 4 days now.
Should I delete account 0 how do I even do that?
Here are 2 reference both dont work for me.
Error HH8: There's one or more errors in your config file: * Invalid value undefined for HardhatConfig.networks.rinkeby.url - Expected a value of t
H88 Error: Invalid account: #0 for network: mumbai - Expected string, received undefined
/* hardhat.config.js */
require("#nomiclabs/hardhat-waffle");
module.exports = {
defaultNetwork: "hardhat",
networks: {
hardhat: {
chainId: 1337
},
mumbai: {
url: "https://rpc-mumbai.maticvigil.com",
accounts: [process.env.privateKey]
}
},
solidity: {
version: "0.8.4",
settings: {
optimizer: {
enabled: true,
runs: 200
}
}
}
}
You are not loading the private key correctly from your .env file.
Do a:
npm install dotenv --save-dev
and add this at the top of your config:
require('dotenv').config()
console.log(process.env) // remove this after you've confirmed it working
The console log should now return your dotenv object
Related
I've installed estherscan from npm, but the verify command is still not present. When I try to verify a contract I get the error that the verify task does not exist.
This is my hardhat.config.js file,
`/**
* #type import('hardhat/config').HardhatUserConfig
*/
require('dotenv').config();
require("#nomiclabs/hardhat-ethers");
const { API_URL, PRIVATE_KEY, ETHERSCAN } = process.env;
module.exports = {
solidity: "0.8.9",
defaultNetwork: "polygon_mumbai",
networks: {
hardhat: {},
polygon_mumbai: {
url: API_URL,
accounts: [`0x${PRIVATE_KEY}`]
}
},
etherscan: {
apiKey: ETHERSCAN
}
}`
When I try to verify I get the error "Error HH303: Unrecognized task verify"
When I run the command npx hardhat I don't see any verify task on the menu
I've tried installing the etherscan verify plugin for hardhat using npm install --save-dev #nomiclabs/hardhat-etherscan
I forgot to import the plugin into hardhat.config.js,
solution is to import it before running the command.
require("#nomiclabs/hardhat-etherscan");
I was following some tutorial and everything worked fine. I decided to make a new project to test myself out. After writing the contracts and making a new ganache workspace, when I run truffle migrate, it just says:
Compiled successfully using:
- solc: 0.8.7+commit.e28d00a7.Emscripten.clang
It doesnt say anything regarding the migrations.
When I run truffle networks, it says: Contracts have not been deployed to any network.
Also, when I run truffle develop, when it lists down the accounts, its showing the old accounts from my older ganache workspace.
truffle-config.js:
module.exports = {
networks: {
ganache: {
host: "127.0.0.1",
port: 7545,
network_id: "*"
},
},
compilers: {
solc: {
version: "^0.8",
optimizer: {
enabled: true,
runs: 200
},
},
},
contracts_directory: './src/contracts/',
contracts_build_directory: './src/abis/',
mocha: {
useColors: true,
},
};
I was trying to deploy an ERC 721 token using truffle in Polygon's mumbai testnet.
And i have 2.8296 Matic in my metasmask wallet which i got from their faucet. But when i try to run
truffle migrate --network matic
it says
Error: *** Deployment Failed ***
"Migrations" could not deploy due to insufficient funds
* Account: 0x12aADAdd301d22c941DACF2cfa7A9e2019972F61
* Balance: 0 wei
* Message: insufficient funds for gas * price + value
* Try:
+ Using an adequately funded account
+ If you are using a local Geth node, verify that your node is synced.
Am i doing something wrong? What sould be the gas and gas price i should mention in truffle config file.
Here is my truffle-config file
module.exports = {
networks: {
development: {
host: "127.0.0.1", // Localhost (default: none)
port: 8545, // Standard Ethereum port (default: none)
network_id: "*", // Any network (default: none)
},
matic: {
provider: () => new HDWalletProvider(process.env.MNEMONIC, `https://rpc-mumbai.maticvigil.com/v1/91fdbb5c2f37c699621ss7d2b8b127fc1a123060
`),
network_id: 80001,
confirmations: 2,
timeoutBlocks: 200,
skipDryRun: true
},
},
// Set default mocha options here, use special reporters etc.
mocha: {
// timeout: 100000
},
enter image description here
I am pretty sure there is no balance of this account 0x12aADAdd301d22c941DACF2cfa7A9e2019972F61 in Mumbai-Testnet
Could not connect to your Ethereum client with the following parameters: - host > 127.0.0.1 - port > 7545 - network_id > * Please check that your Ethereum client: - is running - is accepting RPC connections (i.e., "--rpc" option is used in geth) - is accessible over the network - is properly configured in your Truffle configuration file (truffle-config.js)
Truffle v5.3.9 (core: 5.3.9) Node v16.3.0
This is from this video https://youtu.be/XLahq4qyors?t=1385
AND yes my ganache is opened , my truffle-config.json is configured properly with correct port and all tried other solutions from this work but unfortunately it did not work
My config
require('babel-polyfill');
networks: {
development: {
host: "127.0.0.1",
port: 7545,
network_id: "*" // Match any network id
},
},
contracts_directory: './src/contracts/',
contracts_build_directory: './src/abis/',
compilers: {
solc: {
optimizer: {
enabled: true,
runs: 200
},
evmVersion: "petersburg"
}
}
}```
I'm trying to deploy a contract to rinkeby. I'm using the following command:
$ truffle migrate --networks rinkeby
Compiling your contracts...
===========================
> Compiling ./contracts/Migrations.sol
> Compiling ./contracts/Voting.sol
> Artifacts written to ./public/contracts/build/
> Compiled successfully using:
- solc: 0.5.8+commit.23d335f2.Emscripten.clang
Unknown network "ganache". See your Truffle configuration file for available networks.
Truffle v5.0.22 (core: 5.0.22)
Node v11.6.0
It works witch ganache-cli but it doesn't work with rinkeby, because its giving me the error of Unknown network "ganache". See your Truffle configuration file for available networks as showed in the result above.
This is my truffle-config.js:
module.exports = {
// See <http://truffleframework.com/docs/advanced/configuration>
// to customize your Truffle configuration!
contracts_build_directory: path.join(__dirname, "./public/contracts/build/"),
networks: {
development: {
host: "127.0.0.1",
port: 8545,
network_id: 1000,
gas: 4612388,
gasPrice: 25000000000,
total_accounts: 20,
mnemonic
},
rinkeby: {
provider: () => new HDWalletProvider(mnemonic, infuraURL),
network_id: 4,
gas: 4612388,
gasPrice: 25000000000,
},
},
solc: {
optimizer: {
enabled: true,
runs: 200
}
}
};
For anyone having this error, my problem was that I was writting wrong the command. The correct form should be:
truffle migrate --network rinkeby # Network is without the 's'