Questions tagged [hardhat]

1364 questions
24
votes
1 answer

Where does the line blur between a task and a script in Hardhat?

This is a question about Hardhat, the task runner that facilitates building on Ethereum. From Writing scripts with Hardhat: You can write your custom scripts that can use all of Hardhat's functionality. A classic use case is writing a deployment…
Paul Razvan Berg
  • 17,902
  • 6
  • 73
  • 143
11
votes
4 answers

How to console log output in hardhat test?

I'm using running hardhat tests. When I add console logs to the test cases, nothing actually gets outputted to console. Why's that?
doctopus
  • 315
  • 2
  • 9
11
votes
4 answers

Received invalid block tag 87. Latest block number is 0

I ran a hardhat node just fine using npx hardhat node, but after I shut it down and restarted it, whenever I try to deploy something on the chain, I get the following error: eth_getTransactionCount Received invalid block tag 87. Latest block…
zendevil.eth
  • 303
  • 1
  • 3
  • 10
7
votes
2 answers

Pass command line args to scripts run by hardhat run command

How can I pass positional arguments to script run by npx hardhat run command? Help displays only this: Hardhat version 2.6.8 Usage: hardhat [GLOBAL OPTIONS] run [--no-compile] script OPTIONS: --no-compile Don't compile before running this task…
rlib
  • 289
  • 2
  • 10
6
votes
2 answers

Hardhat - HardhatEthersProvider.resolveName is not implemented

I'm passing the contract address from a bash script export CONTRACT_ADDRESS I verified contractAddress has the correct value in my javascript, but I'm getting NotImplementedError: Method 'HardhatEthersProvider.resolveName' is not…
user125051
  • 73
  • 3
6
votes
2 answers

How to compile external contracts using Hardhat

I want to use a contract in node_modules in my tests, but I'm getting: HardhatError: HH700: Artifact for contract "SomeContract" not found. This is probably because it's not used by any files under /contracts directory, hence not generating the…
5
votes
4 answers

Hardhat deploy contract to predetermined address on localhost dev chain

I am running hardhat. How do I ensure the contract below is always deployed to a specific address on my localhost dev chain, say: 0x5FbDB2315678afecb367f032d93F642f64180aa3: const Factory = await hre.ethers.getContractFactory("FactoryContract"); …
David Simic
  • 182
  • 5
5
votes
0 answers

How to calculate gas fees to deploy smart contract? (on Hardhat OR Truffle)

How to calculate gas fees to deploy smart contract on Hardhat OR Truffle
4
votes
2 answers

Resetting the local hardhat node inside a test suite?

I am testing some deployment features of my contracts, and I would like to reset the local hardhat network to initial state between some of the tests, in particular, to clear out all previously deployed contracts from the test net. (I am not using…
GGizmos
  • 741
  • 6
  • 23
3
votes
2 answers

Trouble getting 'hardhat-shorthand' plugin for Hardhat to work, using 'hh' shortcut only brings up HTML help

I tried installing the hardhat-shorthand plugin and whenever I try using 'hh' in Git Bash it brings up this instead:
Brian Le
  • 33
  • 3
2
votes
0 answers

Can't deploy library with hardhat

So I have this library: library Hasher { function MiMCSponge(uint256 in_xL, uint256 in_xR) public pure returns (uint256 xL, uint256 xR); } And I'm trying to deploy it: const Hasher = await hre.ethers.getContractFactory('Hasher') const hasher =…
doctopus
  • 315
  • 2
  • 9
2
votes
4 answers

How to use HardHat behind a proxy

I'm using HardHat (repo) behind a firewall, requiring outbound connections to use a proxy. This is usually pretty easy, for example to configure NPM for using proxy, you can set environment variables HTTP_PROXY and HTTPS_PROXY. In HardHat, when…
DogEatDog
  • 121
  • 1
  • 7
2
votes
3 answers

Hardhat: How to send multiple transactions to be mined in one block

How to send multiple transactions which will be mined in one block in Hardhat tests?
misterio
  • 21
  • 2
2
votes
1 answer

How to jump into REPL after the execution of an Hardhat script?

Is it possible with Hardhat to launch a script, wait for its completion (or an error), and then jump into the console, with access to the current environment variables? When using eth-brownie, or python in general, you can add the -i flag to achieve…
Yakitori
  • 767
  • 2
  • 14
2
votes
3 answers

Hardhat how to impersonate an account for a local fork without using etherjs

All tutorials show how to impersonate an account using hardhat and etherjs. In my case I create a local mainnet fork and run the tests and create TX using golang so interested to know how to impersonate without using etherjs
1
2 3 4 5