hardhat
hardhat copied to clipboard
'blockConfirmations' does not exist in type 'NetworkUserConfig'.
I got the following error in my hardhat.config.ts
file:
(property) blockConfirmations: number
Type '{ url: string; accounts: string[]; chainId: number; blockConfirmations: number; }' is not assignable to type 'NetworkUserConfig | undefined'.
Object literal may only specify known properties, and 'blockConfirmations' does not exist in type 'NetworkUserConfig'.ts(2322)
The hardhat.config.ts
file:
import "@nomicfoundation/hardhat-toolbox";
import "dotenv/config";
import "@nomiclabs/hardhat-etherscan";
import "./tasks/block-number";
import "hardhat-gas-reporter";
import "solidity-coverage";
import "@typechain/hardhat";
import "hardhat-deploy";
import { HardhatUserConfig } from "hardhat/types/config";
const GOERLI_RPC_URL = process.env.GOERLI_RPC_URL!;
const PRIVATE_KEY = process.env.PRIVATE_KEY!;
const ETHERSCAN_API_KEY = process.env.ETHERSCAN_API_KEY!;
const COINMARKETCAP_API_KEY = process.env.COINMARKETCAP_API_KEY!;
const config: HardhatUserConfig = {
solidity: {
compilers: [{ version: "0.8.9" }, { version: "0.6.6" }],
},
defaultNetwork: "hardhat",
networks: {
goerli: {
url: GOERLI_RPC_URL,
accounts: [PRIVATE_KEY],
chainId: 5,
blockConfirmations: 6, <--- error on this line
},
localhost: {
url: "http://127.0.0.1:8545/",
chainId: 31337,
},
},
etherscan: {
apiKey: ETHERSCAN_API_KEY,
},
gasReporter: {
enabled: true,
outputFile: "./generated/gas-report.txt",
noColors: true,
currency: "USD",
coinmarketcap: COINMARKETCAP_API_KEY,
},
namedAccounts: {
deployer: {
default: 0,
},
},
};
export default config;
The code itself works as soon as I remove the type, but I guess blockConfirmations
is not typed correctly(?). I got a related error in the deploy
file, see:
Property 'blockConfirmations' does not exist on type 'NetworkConfig'.
Property 'blockConfirmations' does not exist on type 'HardhatNetworkConfig'.
This issue is also being tracked on Linear.
We use Linear to manage our development process, but we keep the conversations on Github.
LINEAR-ID: 44359864-6520-467f-8dcf-830641dcaddf
Hey! Thanks for opening this issue.
Can you share a repository to reproduce this?
Hey! Thanks for opening this issue.
Can you share a repository to reproduce this?
Sure! You can find the repo here. See file hardhat.config.ts
and 01-deploy-fund-me.ts
.
We don't have a configuration property like that (docs). Did you see that option in our docs or in some other resource?
We don't have a configuration property like that (docs). Did you see that option in our docs or in some other resource?
I found it during a freeCodeCamp course, you can find it here: video
At 11:57:10 he demonstrates it.
In the meantime I removed the type in the hardhat.config.ts
and added a ts-ignore
in the test file. The code itself runs fine, but it's just a type issue so far.
Hello! Looks like this was a bit of an overstep by me, using tools for not what they were designed for. You can see I have a typescript edition of my code here: https://github.com/PatrickAlphaC/hardhat-fund-me-fcc/blob/84271e7002e55d86c90b26466ff27bc067f25de0/deploy/01-deploy-fund-me.ts#L29
So hardhat-deploy
has the waitConfirmations, which we used to wait X blocks after deploying a contract. In javascript, since JS doesnt have type checking, we just added our blockConfirmations
right in the hardhat.config.js
, however in our typescript edition, we added it in our networkConfig
file.
You can see this difference in the typescript branch of this repo.
Could you make an issue/PR to our repo with this? https://github.com/smartcontractkit/full-blockchain-solidity-course-js
Looks like we should just clarify the differences I did in the javascript vs typescript for the blockconfirmations.
Hello! Looks like this was a bit of an overstep by me, using tools for not what they were designed for. You can see I have a typescript edition of my code here: https://github.com/PatrickAlphaC/hardhat-fund-me-fcc/blob/84271e7002e55d86c90b26466ff27bc067f25de0/deploy/01-deploy-fund-me.ts#L29
So
hardhat-deploy
has the waitConfirmations, which we used to wait X blocks after deploying a contract. In javascript, since JS doesnt have type checking, we just added ourblockConfirmations
right in thehardhat.config.js
, however in our typescript edition, we added it in ournetworkConfig
file.You can see this difference in the typescript branch of this repo.
Could you make an issue/PR to our repo with this? https://github.com/smartcontractkit/full-blockchain-solidity-course-js
Looks like we should just clarify the differences I did in the javascript vs typescript for the blockconfirmations.
Thank you for the response, that makes a lot of sense! As requested I opened an issue in your repo, see issue#1707. Will take a look tomorrow to create a PR.
Thanks all for thinking along and the help!