hardhat icon indicating copy to clipboard operation
hardhat copied to clipboard

'blockConfirmations' does not exist in type 'NetworkUserConfig'.

Open RowinVanAmsterdam opened this issue 1 year ago • 3 comments

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'.

RowinVanAmsterdam avatar Aug 09 '22 18:08 RowinVanAmsterdam

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

github-actions[bot] avatar Aug 09 '22 18:08 github-actions[bot]

Hey! Thanks for opening this issue.

Can you share a repository to reproduce this?

alcuadrado avatar Aug 09 '22 21:08 alcuadrado

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.

RowinVanAmsterdam avatar Aug 10 '22 10:08 RowinVanAmsterdam

We don't have a configuration property like that (docs). Did you see that option in our docs or in some other resource?

fvictorio avatar Aug 10 '22 13:08 fvictorio

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.

RowinVanAmsterdam avatar Aug 10 '22 15:08 RowinVanAmsterdam

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.

PatrickAlphaC avatar Aug 11 '22 19:08 PatrickAlphaC

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.

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!

RowinVanAmsterdam avatar Aug 11 '22 20:08 RowinVanAmsterdam