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 3 years ago
This release fixes a Hardhat issue triggered by the latest versions of ethereumjs. If you have an error with a message like Cannot read property 'gteHardfork' of undefined
or opts.tx.supports is not a function
, please upgrade Hardhat to this version.
Published by fvictorio over 3 years ago
This release adds support for verifying contracts in the Mumbai testnet.
Published by fvictorio over 3 years ago
This release removes the warning shown by Hardhat when Solidity 0.8.x is used. Keep in mind that we currently support Solidity versions up to 0.8.4. Check the Solidity Support section of our docs to learn more.
Published by fvictorio over 3 years ago
This release adds support for Solidity 0.8.x, as well as multiple new features for customizing the behavior of the Hardhat Network.
Some error messages returned by Hardhat have changed. If you have tests that check the exact message of a Hardhat error, you may need to update them.
For example, before this release a require(false, "this is the reason")
statement would've generated this error message:
Error: VM Exception while processing transaction: revert this is the reason
In this new version, the error message will be:
Error: VM Exception while processing transaction: reverted with reason string 'this is the reason'
You'll also get different error messages for panic errors (for example, if you are using solidity 0.8.0 and divide by zero) and for custom errors. See below to learn more about these new features.
Hardhat now recognizes custom errors. For example, given this contract:
contract Foo {
error MyCustomError(uint code, string message);
function test() public {
revert MyCustomError(42, "failed for some reason");
}
}
If you deploy Foo
and call its test
method, you'll now get a stack trace like this:
Error: VM Exception while processing transaction: reverted with custom error 'MyCustomError(42, "failed for some reason")'
at Foo.test (contracts/Foo.sol:5)
Keep in mind that Hardhat can only recognize custom errors that are defined within your project. If you use mainnet forking and call some external contract that reverts with a custom error, Hardhat won't be able to parse it, and it will show an unrecognized error instead.
Solidity 0.8.0 introduced the concept of panic codes. In previous solidity versions, internal errors like dividing by zero were signaled by an invalid opcode being executed. The problem with this was that there wasn't a way to detect what kind of internal error was thrown and, worse, an error like this would consume all the remaining gas available in the transaction. Now, instead of using an invalid opcode, these errors use the revert
opcode (the same used by the require
function) and include a code that indicates what was the problem that caused the error.
For example, if you deploy this contract:
contract Foo {
function test(uint x) public {
uint y = 1 / x;
}
}
and then you call the test
function with value 0, Hardhat will now show a stack trace like this:
Error: VM Exception while processing transaction: reverted with panic code 0x12 (Division or modulo division by zero)
at Foo.test (contracts/Foo.sol:3)
Hardhat now understands and generates correct stack traces when a top-level function is part of the call stack.
Hardhat v2.4.0 includes several new RPC methods that let you modify anything about an address:
hardhat_setNonce
This method lets you change the nonce of an account. For example:
await network.provider.send("hardhat_setNonce", ["0x0d2026b3EE6eC71FC6746ADb6311F6d3Ba1C000B", "0x21"])
This will result in account 0x0d20...000B
having a nonce of 33.
You can only use this method to increase the nonce of an account; you can't set a lower value than the account's current nonce.
hardhat_setBalance
This method lets you change the balance of an account. For example:
await network.provider.send("hardhat_setBalance", ["0x0d2026b3EE6eC71FC6746ADb6311F6d3Ba1C000B", "0x1000"])
This will result in account 0x0d20...000B
having a balance of 4096 wei.
hardhat_setCode
This method lets you set the bytecode of an address. For example:
await network.provider.send("hardhat_setCode", ["0x0d2026b3EE6eC71FC6746ADb6311F6d3Ba1C000B", "0xa1a2a3..."])
This will result in account 0x0d20...000B
becoming a smart contract with bytecode a1a2a3...
. If that address was already a smart contract, then its code will be replaced by the specified one.
hardhat_setStorageAt
This method lets you modify any position in the storage of a smart contract. For example:
await network.provider.send("hardhat_setStorageAt", [
"0x0d2026b3EE6eC71FC6746ADb6311F6d3Ba1C000B",
"0x0",
"0x0000000000000000000000000000000000000000000000000000000000000001"
])
This will set the first storage position inside that contract to 1
.
The mapping between a smart contract's variables and its storage position is not straightforward except in some very simple cases. For example, if you deploy this contract:
contract Foo {
uint public x;
}
And you set the first storage position to 1 (as shown in the previous snippet), then calling foo.x()
will return 1.
You can now configure Hardhat Network so that it only mines transactions that have a gas price equal to or above a given threshold. If automining is enabled, transactions with a lower gas price will be rejected. If automining is disabled, this transactions will be kept in the mempool but they won't be mined.
To configure the minimum gas price, set the minGasPrice
property in the Hardhat Network configuration:
module.exports = {
networks: {
hardhat: {
minGasPrice: 1_000_000_000
}
}
}
You can also change this value in runtime using the new hardhat_setMinGasPrice
RPC method:
await network.provider.send("hardhat_setMinGasPrice", ["0x77359400"])
Hardhat now supports transaction replacement when automining is disabled. This means that if you send a transaction from the same address and with the same nonce as another transaction already present in the mempool, but with a higher gas price, this transaction will be replaced. The new gas price needs to be at least 10% higher than the gas price of the current transaction.
There is a new hardhat_dropTransaction
RPC method that can be used to remove transactions from the mempool:
const txHash = "0xabc..."
const result = await network.provider.send("hardhat_dropTransaction", [txHash])
There are three possible scenarios when this method is used:
txHash
corresponds to a transaction in the mempool. In this case, the transaction will be removed and result
will be true
.txHash
doesn't correspond to a transaction. In this case nothing will happen and result
will be false
.txHash
corresponds to a mined transaction. In this case an InvalidArgumentsError
will be thrown.Hardhat now supports the HTTP_PROXY
and HTTPS_PROXY
environment variables. This is only used to download the Solidity compilers, not for JSON-RPC networks or mainnet forking. Thanks @cdesch for working on this! (PR #1291, issue #1280)
When the balance of an account was set to a hexadecimal value, Hardhat would throw a very opaque error. Now a better error message is shown. Thanks to @Bidon15 for this contribution! (PR #1458, issue #1427)
Forking from xDai will cache data to disk if you ping a block older with 38 confirmations or more. Thanks to @jacobrosenthal for this! (PR #1557)
Published by fvictorio over 3 years ago
This release adds support for verifying contracts deployed on the Optimism networks (Optimistic Ethereum, Optimistic Kovan) and in the Matic (Polygon) POS Network.
Thanks to @ayushm2003 and @BrknRobot for their contributions! 👷♂️
Published by fvictorio over 3 years ago
This release fixes an issue introduced by recent versions of ethereumjs. If you see an error like TypeError: Cannot read property 'param' of undefined
or TransactionExecutionError: Assertion failed
, please upgrade to this version and try again. See #1537 to learn more.
Published by fvictorio over 3 years ago
This release adds support for the debug_traceTransaction
RPC method, along with some other minor changes.
debug_traceTransaction
The debug_traceTransaction
method receives the hash of a transaction and returns a low-level structure that describes how the EVM executed that transaction. This is mainly useful for higher-level tools, and it's a major step towards letting Brownie integrate with Hardhat.
debug_traceTransaction
can be used both in local and fork modes. This means that you can use it with any transaction in mainnet, even if the node you are using doesn't support this method. If you use an archive node, you can trace any historical transaction after the Spurious Dragon fork (2016).
You can read more about this method here, but notice that Hardhat doesn't support the tracer
and timeout
options.
When a sent transaction fails, the JSON-RPC node will include its hash in the response. This is another component needed to better integrate Brownie with Hardhat, but it's also useful for any tool that wants to leverage it. The JSON response of a failed transaction now looks like this:
{
"jsonrpc": "2.0",
"id": 1,
"error": {
"code": -32603,
"message": "Error: VM Exception while processing transaction: revert failed",
"data": {
"txHash": "0x03a5b783cfd268687f95b741c92ae7e2e7dc611535d6b4f2a8d291df410c33cc"
}
}
}
This release also includes two minor improvements (thanks to @Bidon15 for these contributions!):
--verbose
flag, the output will include the path to the hardhat config file that was loaded. This is useful when you are trying to initialize a project, but Hardhat detects a config file in an upper directory. Issue: #1443, PR: #1454.Published by fvictorio over 3 years ago
This release adds support for the HECO and fantom networks to the etherscan plugin.
Published by fvictorio over 3 years ago
This release fixes a bug where a contract's code was not being properly removed after a selfdestruct
(#1415).
Published by alcuadrado over 3 years ago
Hardhat v2.2.0, which includes support for the new Berlin hard fork, has been released.
This version also includes some small fixes, most notably, it fixed some problems when downloading solc on MacOS.
To workaround a recently discovered bug in @ethereumjs/vm
, this release saves the EVM state in a non-standard way which can't produce valid state roots.
What this means in practice is that the state root in block headers is not valid. If your tests don't depend on it, they should work correctly.
Note that this same limitation is always present when forking from another network, so if you are using this feature, you can ignore this section.
As soon as this issue is fixed upstream, we'll publish a new version which will compute valid state roots again.
This version changes Hardhat Network's default config to match Mainnet's behavior:
hardfork
is now "berlin"
.blockGasLimit
is now 12450000
(a reasonable value for Mainnet blocks at the time of the release).gas
matches the block gas limit value.eth_estimateGas
that was triggered when running it with an old block (#1366)eth_sendTransaction
, eth_estimateGas
, and eth_call
match those of Geth. eth_estimateGas
now ignores the nonce
field. (#1366)@ethereumjs/vm
v5 (#1337 #1370 #1394)@etheruemjs/vm
's DefaultStateManager
(#1406)Published by fvictorio over 3 years ago
This release makes it easier to use a custom VM with hardhat. Most users shouldn't be affected by this change.
This release also fixes an issue with mainnet forking when using ArchiveNode.io as the remote node.
Published by fvictorio over 3 years ago
This release adds a new getSigner
method that can be used with an address to get a signer object for that address:
const signer = await ethers.getSigner("0xabc...");
Of course, this signer can be used for writing only if that address is unlocked. Otherwise it can be used in a read-only fashion.
This release also fixes getContractAt
so that, if there are no signers available, you still get a contract instance that can only be used for read operations.
Finally, it's now possible for a typescript plugin to declare which methods are added to the ethers
object.
Published by fvictorio over 3 years ago
This release fixes a bug introduced in 2.1.0 that was causing the gas estimation to be executed in the context of the latest block and not in the pending ("next") block.
Published by fvictorio over 3 years ago
This release adds mempool support to Hardhat, with two possible mechanisms for mining transactions: automining (the current behavior) and interval mining. You can also disable both mechanisms and mine new blocks programmatically. Check the docs to learn more.
Besides that:
eth_getStorageAt
was fixed (thanks @fubhy!)Published by fvictorio over 3 years ago
This release fixes two bugs in the Hardhat Network.
The first one was related to how internal errors were handled during a fork. If you were seeing revert errors in some runs but not in others, this version should fix that.
The second bug was a race condition that caused the fork to sometimes throw an error about an nonexistent directory when it was started.
Published by fvictorio over 3 years ago
This release adds support for mixing Solidity and Vyper files in the same project.
Thanks a lot to @transferAndCall for working on this!
Published by fvictorio over 3 years ago
This PR fixes a problem introduced in v2.0.9 that caused Hardhat to stop working with node 14.
Besides that, there are two important fixes to mainnet forking:
Huge thanks to @fubhy for contributing to this release!
Published by fvictorio over 3 years ago
This release adds support for forking the Kovan and xDAI networks. Plus:
eth_signTypedData_v4
RPC method is now supported and the eth_signTypedData
was removed since its EIP is not finished.console.log
was fixed (see #1182)Published by fvictorio over 3 years ago
This release includes some improvements to the hardhat-etherscan
plugin.
The plugin tries to automatically detect the contract that is being verified, but sometimes you can have two different contracts that generate the same bytecode. In previous versions this meant that you couldn't verify those contracts without modifying one of them. Now you can use the --contract
parameter to specify which of the ambiguous contracts should be used.
The plugin also tries to detect which libraries are linked to the contract that is being verified, but there are some edge cases where this is not possible (for example, if a library is only used in the constructor). Now you can use the --libraries
parameter to pass these undetectable libraries. Learn more here.
We added support for BSC and its testnet. Huge thanks to @purperen and @guagualvcha who contributed to this.
Published by alcuadrado almost 4 years ago
This is release includes the following improvements and bug fixes:
SSTORE
in Hardhat Network when it runs in fork mode (https://github.com/nomiclabs/hardhat/pull/1172)HH9
(https://github.com/nomiclabs/hardhat/pull/1165)r
and s
in Hardhat Network (https://github.com/nomiclabs/hardhat/pull/1158)hardhat/console.sol
in projects that have a hardhat
directory (https://github.com/nomiclabs/hardhat/pull/1162)