This Hardhat 3 Alpha release adds a new plugin, @nomicfoundation/hardhat-viem-matchers
, to our Viem toolbox and Viem starter project. The plugin provides Ethereum-specific testing assertion functions that work with Viem.
The new @nomicfoundation/hardhat-viem-matchers
plugin is included automatically when you install a new Viem project with hardhat —init
.
Here is an example of using the balancesHaveChanged
matcher:
const { viem } = await hre.network.connect();
const [bobWalletClient, aliceWalletClient] = await viem.getWalletClients();
await viem.assertions.balancesHaveChanged(
bobWalletClient.sendTransaction({
to: aliceWalletClient.account.address,
value: 1000000000000000n,
}),
[
{
address: aliceWalletClient.account.address,
amount: 1000000000000000n,
},
],
);
See the README.md
for reference documentation: https://github.com/NomicFoundation/hardhat/blob/v-next/v-next/hardhat-viem-matchers/README.md#reference
Changes
💡 The Nomic Foundation is hiring! Check our open positions.