Hardhat is a development environment to compile, deploy, test, and debug your Ethereum software.
OTHER License
Bot releases are hidden (Show)
Published by fvictorio over 1 year ago
This release fixes a bug related to using contract.waitForDeployment
in non-automined networks (https://github.com/NomicFoundation/hardhat/issues/4006).
Published by fvictorio over 1 year ago
This version of hardhat-verify
removes the compilation step from the verify task, and drops the noCompile
flag. This means that the project is never compiled when you verify a contract.
Published by fvictorio over 1 year ago
This new version of Hardhat uses the new ethers v6 based Toolbox when initializing a project. Check the release notes of the Toolbox to learn more.
Published by fvictorio over 1 year ago
This version removes a dependency from the package that was no longer necessary.
Published by fvictorio over 1 year ago
This version adds support for transaction overrides in the deployContract
helper. For example, if you want to set the gas limit of a deployment transaction, you can do this:
const contract = await hre.ethers.deployContract("MyContract", [constructorArg1, constructorArg2], {
gasLimit: 1_000_000
})
Published by fvictorio over 1 year ago
This new major version of Hardhat Toolbox is based on ethers v6 and uses new versions of the hardhat-ethers
, hardhat-chai-matchers
and typechain plugins.
Nothing has changed in how you use the Toolbox for a new project: if you initialize one with the latest version of Hardhat, then this version of the Toolbox will be used. Check our Setting up a project guide for the complete instructions.
To use this new version of the Toolbox in an existing project, you need to upgrade the Toolbox and its relevant peer dependencies.
If you are using npm 7 or later, you just need to upgrade the Toolbox and npm will handle the rest:
npm install @nomicfoundation/hardhat-toolbox@3
If you are using yarn or an older version of npm, you’ll need to manually upgrade all the relevant packages and remove the ones that are no longer needed:
# upgrade relevant packages
yarn add @nomicfoundation/hardhat-toolbox@3 @nomicfoundation/hardhat-chai-matchers@2 @nomicfoundation/hardhat-ethers@3 @nomicfoundation/hardhat-verify @typechain/ethers-v6 @typechain/hardhat@8 ethers@6
# remove packages that are no longer needed
yarn remove @ethersproject/abi @ethersproject/providers @nomiclabs/hardhat-ethers @nomiclabs/hardhat-etherscan @typechain/ethers-v5
Ethers v6 has several changes with respect to v5. These are some of them, but check their migration guide for the full details.
One of the most important changes in v6 is that now native bigints are used instead of BigNumber objects. For example, checking if an address has a positive amount of tokens is done like this in v5:
const balance = await token.balanceOf(someAddress)
if (balance.gt(0)) {
// ...
}
While in v6 you would do it this way:
const balance = await token.balanceOf(someAddress)
if (balance > 0n) {
// ...
}
For more info on native bigints, check the MDN page.
ethers.utils
In ethers v6, ethers.utils
doesn’t exist anymore. In many cases, just removing .utils
is enough to adapt your code, but other functions were renamed. Again, check ethers’s migration guide to learn more.
Sending ether to a contract was done like this in ethers v5:
await signer.sendTransaction({
to: contract.address,
value: ethers.utils.parseEther("0.1")
})
In ethers v6, you can just use the contract instance:
await signer.sendTransaction({
to: contract,
value: ethers.parseEther("0.1")
})
Contract instances in ethers v5 had a .address
property with the address of the contract. In ethers v6 this was replaced by an async .getAddress()
function. That is, before you would do this:
console.log("Contract deployed at", contract.address)
Now you have to do this:
console.log("Contract deployed at", await contract.getAddress())
Alternatively, you can use the .target
property, but keep in mind that this might not work in some scenarios (for example, if you create a contract instance with an ENS address).
.deployed
methodThe .deployed()
method of contracts is now called .waitForDeployment()
When the Toolbox is installed using npm 7 or later, its peer dependencies are automatically installed. However, these dependencies won't be listed in the package.json
. As a result, directly importing the Network Helpers can be problematic for certain tools or IDEs. To address this issue, this new version of the Toolbox re-exports the Hardhat Network Helpers. You can use them like this now:
import helpers from "@nomicfoundation/hardhat-toolbox/network-helpers";
Published by fvictorio over 1 year ago
This new major version of Hardhat Chai Matchers works with the new version of our hardhat-ethers plugin. If you are going to use ethers v6, this is the version that you have to install. If you are still using ethers v5, then you should keep using version 1.x of this plugin.
As part of that, we dropped support for ethers v5's BigNumbers in this version. No other breaking changes were introduced to the API.
Published by fvictorio over 1 year ago
This new major version of hardhat-ethers
uses ethers v6 instead of v5. Notice that the name of the plugin has changed too: the previous version was called @nomiclabs/hardhat-ethers
but this one is called @nomicfoundation/hardhat-ethers
(read this if you wonder why).
Our Toolbox doesn't work with this new version yet, but we'll release a new version that does as soon as possible. If you want to use this plugin in a new project, you'll have to install it, and any other plugin, manually. Also, keep in mind that Typechain's Hardhat plugin doesn't work with this new version yet, but it will soon.
To learn about the changes introduced in ethers v6, read their migration docs.
Published by fvictorio over 1 year ago
This release adds better information to Hardhat about which block numbers correspond to which hardforks. Most users won't be affected by this, but it fixes some issues for certain edge cases.
Published by fvictorio over 1 year ago
This release sets Shanghai as the default hardfork used by the Hardhat Network.
If for some reason you want to keep using the previous hardfork, set it explicitly in your config:
module.exports = {
networks: {
hardhat: {
hardfork: "merge"
}
}
}
Published by fvictorio over 1 year ago
This release adds support for the upcoming Shanghai hardfork. This hardfork is not enabled by default; if you want to use it, then you have to enable it in your Hardhat config:
module.exports = {
networks: {
hardhat: {
hardfork: "shanghai"
}
}
}
Besides that, this version fixes a problem when importing scoped packages in a Yarn Berry monorepo that uses PnP (thanks @zouguangxian!)
Published by fvictorio over 1 year ago
Update solhint to v3.4.0 (thanks @yhuard!)
Published by fvictorio over 1 year ago
Make getContractFactory
's params validation more flexible (thanks @jtakalai!)
Published by fvictorio over 1 year ago
Fixed a bug in how the configured sources paths are compared (thanks @bingryan!)
Published by fvictorio over 1 year ago
This version of the hardhat-vyper
plugin downloads Vyper compilers from a mirror maintained by us instead of using GitHub. This should prevent rate-limiting issues and make downloads much more resilient.
Published by fvictorio over 1 year ago
This version of hardhat-etherscan
improves how already verified contracts are handled. In previous versions, verification would be attempted and an error would be returned by the server. Starting from this version, the plugin will detect that the contract is already verified and show a message informing the user about this. Thanks @OptimusOpus for working on this!
Besides that, this version adds support for Gnosis Chain's Chiado testnet.
Published by fvictorio over 1 year ago
This release has a very minor change that makes the toolbox work correctly in ESM projects. ESM can only be used with Hardhat v2.13.0 or later.
Published by fvictorio over 1 year ago
This new version of Hardhat adds two long-awaited features: ES Modules support, and better support for solc’s IR-based compilation pipeline. Besides that, this version includes several other improvements and bug fixes.
Remember to give this repo a star ⭐ if you are enjoying Hardhat!
Hardhat was designed with CommonJS in mind, but in the last years adoption of ES Modules (ESM) has been growing. This version includes better support for it. You can now write scripts and tests as ESM, but your Hardhat config —and anything imported from it— still needs to use CommonJS.
ES modules let you use import
/export
and top-level await. This means that instead of writing a script like this:
// script.js
const helpers = require("@nomicfoundation/hardhat-network-helpers");
async function main() {
const latestBlockNumber = await helpers.time.latestBlock();
console.log("Latest block:", latestBlockNumber);
}
main()
.then(() => process.exit(0))
.catch(error => {
console.error(error);
process.exit(1);
});
you can now write a less verbose ESM script:
// script.mjs <-- notice the extension
import helpers from "@nomicfoundation/hardhat-network-helpers";
const latestBlockNumber = await helpers.time.latestBlock();
console.log("Latest block:", latestBlockNumber);
Check our guide about Using ES modules with Hardhat to learn more.
Huge thanks to @phated, who started the work on this and helped us along the way.
The solc
compiler has a newer, alternative way of generating bytecode through an intermediate representation (IR). Previous versions of Hardhat don’t work well with this compilation mode, especially when the optimizer is fully-enabled.
This release adds better support for the IR compilation pipeline, but you might still get some issues if you use the default settings. We recommend enabling the minimal necessary optimization steps when compiling with IR:
solidity: {
version: "0.8.18",
settings: {
viaIR: true,
optimizer: {
enabled: true,
details: {
yulDetails: {
optimizerSteps: "u:",
},
},
},
},
}
You can learn more about Hardhat and IR here.
In addition to ES Modules and compiling with the IR-based pipeline, this version includes these improvements and bug fixes:
resolveJsonModule
compiler option is now enabled by default in the sample tsconfig (thanks @mlshv!)e443b3667: Added an option in Hardhat Network to allow mining blocks with the same timestamp
c23a1cac4: Added support for the http_proxy
environment variable. When this variable is set, Hardhat will send its requests through the given proxy for things like JSON-RPC requests, mainnet forking and downloading compilers.
We also removed support for the HTTP_PROXY
and HTTPS_PROXY
environment variables, since http_proxy
is the most commonly used environment variable for this kind of thing. Those variables could only be used for downloading compilers.
Finally, we also added support for no_proxy
, which accepts a comma separated list of hosts or "*"
. Any host included in this list will not be proxied.
Note that requests to "localhost"
or "127.0.0.1"
are never proxied.
69546655e: Added support for sending batch requests through WebSocket to the Hardhat node (thanks @tenbits!)
6bf1673bb: Added a config validation for the number of optimizer runs used (thanks @konarshankar07!)