Skip to main content
18 votes
Accepted

Error HH210: Redefinition of task verify failed. Unsupported operation adding positional param definitions in an overridden task

I had the same problem with hardhat-verify. Switch to hardhat-toolbox solved the problem. Since you already has require("@nomicfoundation/hardhat-toolbox") you should remove require("@...
Дмитрий Смирнов's user avatar
12 votes
Accepted

ProviderError: max code size exceeded

How can I adjust the code size or any other method to resolve this error. The contract code size limit is 24kB (24,576 bytes). You'll need to reduce the size of the contract before deploying, or ...
Richard Horrocks's user avatar
10 votes
Accepted

What is the difference between getSigners and getNamedAccounts?

getSigners and getNamedAccounts are both used for the same purpose, getting public key for accounts. Since you asked for getNamedAccounts I assume you are developing on a hardhat environment because ...
jutsu's user avatar
  • 143
9 votes

Learning hardhat. What is the difference between deploying to localhost and hardhat network?

Hardhat has a local ethereum network that is run in two flavors. The "hardhat" network is run in-process, while the "localhost" version is run as a standalone daemon, enabling JSON-...
Ghasem Kiani's user avatar
8 votes
Accepted

Transaction reverted: trying to deploy a contract whose code is too large

In this case, the problem was the mal-formed hardhat.config.js file. Here is what should solve the problem: module.exports = { solidity: { version: "0.8.9", settings: { ...
Jean-François Beaulieu's user avatar
6 votes
Accepted

I can't deploy large contracts with Optimizer enabled

Optimizer is supposed to help your large code achieve maximum efficiency so it runs and can be deployed. Increasing the runs value from 20 to 500 may work.
Akay Udeh's user avatar
6 votes

How to get ABI of deployed contract using ethersjs in hardhat?

If you are deploying by command line, you can read from the file where is previously builded, in the case of hardhat there is a example: const fs = require("fs") const path = require("...
Nicolas Sturm's user avatar
5 votes
Accepted

hardhat-deploy: ProviderError: The method evm_snapshot does not exist/is not available

The fixture functionality currently doesn't work for testnets. If you want to run your tests on a testnet, you'll first have to deploy the contracts, and then run your tests.
Patrick Collins's user avatar
5 votes
Accepted

Cannot read properties of undefined (reading 'gteHardfork') when deploying contract using hardhat

Upgrading hardhat should fix your problem: npm i --save-dev hardhat@latest The reason why this happened is that there are some compatibility issues between older versions of hardhat and newer ...
Franco Victorio's user avatar
5 votes
Accepted

hardhat does not find artifact when deploying

Well, I managed to find out what was wrong. The contract filename and the contract definition were different. I don't know if the filename of the contract and the contract definition has to be the ...
Iván's user avatar
  • 181
5 votes

ProviderError: max code size exceeded

you can try Above mentioned steps but before doing any of that, Please try compilerOptimization setting in hardhat.config.js. IMO, use at least 1000 runs which will optimize your deployment a lot ...
GraphicalDot's user avatar
5 votes
Accepted

hardhat-deploy deterministic deployment

In order to use Create2 and get the same address, you have to pass the same variables: create2(someValueToPreventCollisionWithCreate, msg.sender, salt, contractBytecode) So if your contractBytecode ...
Patrick Collins's user avatar
5 votes

Help Please hardhat.config.js * Invalid account: #0 for network: Rinkeby - private key too short, expected 32 bytes

Make sure you are copying your PRIVATE KEY and not your PUBLIC KEY. If you are using metamask, you can get your PRIVATE KEY from the 3 dots menu beside your public key, and then account details ...
Alejandro Morales's user avatar
5 votes

Help Please Solidity version pragma statement in these files doesn't match the configured compilers in your config*contracts/hello-world.sol ("0.8.4")

try this: at hartdhat.config.js module.exports = { solidity: "0.7.1", }; 0.7.1--> 0.8.4 (solidity version you use in the smart contract) if not work, comment below, or git upload code ...
aakash4dev's user avatar
4 votes

Property 'getContractFactory' does not exist on type?

ethers.getContractFactory is a one of the helpers that Hardhat added to the ethers object so you need to call hre first. https://hardhat.org/plugins/nomiclabs-hardhat-ethers.html#helpers Notice ...
Ryan Sea's user avatar
  • 638
4 votes
Accepted

How to interact with a deployed contract in a script/task using hardhat-deploy

A common "gotcha" of hardhat deploy. You have to use --network localhost when running a script with your own hardhat node locally. The default network is the hardhat network otherwise.
Patrick Collins's user avatar
4 votes

Error HH8: There's one or more errors in your config file, Expected a value of type HttpNetworkConfig

You're getting this error because hardhat needs to be able to verify that the URL and accounts you're using for a network are valid for that network. In your specific case, your Private key isn't ...
Patrick Collins's user avatar
4 votes
Accepted

Error HH8: There's one or more errors in your config file, Expected a value of type HttpNetworkConfig

had to run source .env to enable the .env in Ubuntu 20.04 LTS
GoGetterMeme's user avatar
4 votes
Accepted

Can hardhat deploy contract by metamask?

Hardhat is a backend platform. Metamask lives in your browser. They are not meant to communicate like that. So you can't deploy your contract through Hardhat by utilizing private keys inside Metamask. ...
Lauri Peltonen's user avatar
4 votes

Can hardhat deploy contract by metamask?

This can be achieved with the help of this npm library: https://www.npmjs.com/package/hardhat_metamask_client The approach of the library is a little tricky due to the fact that hardhat doesn't meant ...
Navid Far's user avatar
4 votes
Accepted

Hardhat deploy TypeError: ethers.getContract is not a function

I recognize that deploy script anywhere. It's what i learned from Patrick and just like you i got this problem too. Its a hardhat-ethers problem and you will need to install hardhat-deploy-ethers as ...
JamalTheAtlantean's user avatar
4 votes
Accepted

Is there any automatic solution to remove comments and console.log from solidity files?

Yes, there is Hardhat plugin called hardhat-log-remover that can do this for you. You just add it as a plugin in your Hardhat config, and then you can run it from the terminal like this: $ yarn run ...
Paul Razvan Berg's user avatar
4 votes
Accepted

How to get deployed contract address with ethers?

The answer by @AlexanderHerranz is for ethers v5, for newer versions of hardhat that use ethers v6 you can get the deployed address using the async getAddress() method as shown below: const ...
MShakeG's user avatar
  • 1,723
4 votes

How to deploy a contract using hardhat and ethersjs v6

Try two things: Comment out the require statement. Directly use deployContract function. const mynft= await ethers.deployContract("MyNFT"); await wallet.waitForDeployment(); Also notice ...
Zartaj Afser's user avatar
  • 4,396
3 votes
Accepted

Hardhat writing tests for contract that calls another contract

Final solution with help of @LauriPeltonen: I am just deploying my dai contract in beforeEach and then taking its address and passing it to the contract constructor. Solidity: address public ...
David's user avatar
  • 153
3 votes

I can't deploy large contracts with Optimizer enabled

I came across same problem once, this setting below worked for me settings: { optimizer: { enabled: true, runs: 200, details: { yul: false }, }, },
Muhammad Usman's user avatar
3 votes

how to deploy smart contract using hardhat via specific signer/owner

Since we have provided from address in our hardhat config so we can easily access that address from network config & use as contract owner as below. deploy.js const { network,ethers } = require(&...
Gobi Part's user avatar
3 votes

TypeError: Cannot read property 'length' of undefined - While deploying using hardhat

I got the answer from the MASTER himself, @PatrickAlphaC. When we call await getNamedAccounts in the above code, hardhat looks for the length of the named accounts in our hardhat.config.js We have to ...
Rishav Sharma's user avatar
3 votes

Help Please Solidity version pragma statement in these files doesn't match the configured compilers in your config*contracts/hello-world.sol ("0.8.4")

it needs to match up with what's in module.exports in your hardhat.config.js but the quotes in the contract are causing the problem try this pragma solidity ^0.8.4;
sola24's user avatar
  • 1,238
3 votes

What is the difference between getSigners and getNamedAccounts?

If I write getNamedAccounts instead of getSigners in my code, the code won't run ? Because you are using named accounts. That's why getNamedaccounts results in an error. Check your hardhat.config, ...
sms's user avatar
  • 191

Only top scored, non community-wiki answers of a minimum length are eligible