Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
@matterlabs/hardhat-zksync-chai-matchers
Advanced tools
Readme
zkSync Era's integration into the Chai assertion library is enabled by this Hardhat plugin, adding capabilities that make writing and reading smart contract tests easy."
Ensure you are using the correct version of the plugin with ethers:
For plugin version <1.0.0:
For plugin version ≥1.0.0:
To install hardhat-zksync-chai-matchers plugin, run:
npm install -D @matterlabs/hardhat-zksync-chai-matchers
or
yarn add -D @matterlabs/hardhat-zksync-chai-matchers @nomicfoundation/hardhat-chai-matchers chai @nomiclabs/hardhat-ethers ethers
After installing it, add the plugin to your Hardhat config:
import "@matterlabs/hardhat-zksync-chai-matchers";
Then you'll be able to use the matchers in your tests.
changeEtherBalance
Assert that the ether balance of an address changed by a specific amount:
await expect(() =>
sender.transfer({
to: receiver.address,
amount: 2000,
})
).to.changeEtherBalance(sender.address, -2000);
changeTokenBalance
Assert that an ERC20 token balance of an address changed by a specific amount:
await expect(sender.transfer({ to: receiver.address, amount: 5, token: token.address })).to.changeTokenBalance(token, sender, -5);
await expect(token.transfer(receiver.address, 5)).to.not.changeTokenBalance(token, sender, 0);
revertedWithCustomError
Assert that a transaction reverted with a specific custom error:
await expect(contract.setAmount(100)).to.be.reverted;
You can also use regular chai matchers like:
await expect(contract.setAmount(100)).to.emit(contract, "AmountUpdated");
expect("0x36615Cf349d7F6344891B1e7CA7C72883F5dc049").to.be.properAddress;
expect(await contract.getAmount()).to.equal(100);
In addition to the hardhat-zksync-chai-matchers, zkSync's Era website offers a variety of resources including:
Guides to get started: Learn how to start building on zkSync Era.
Hardhat zkSync Era plugins: Overview and guides for all Hardhat zkSync Era plugins.
Hyperscaling: Deep dive into hyperscaling on zkSync Era.
Contributions are always welcome! Feel free to open any issue or send a pull request.
Go to CONTRIBUTING.md to learn about steps and best practices for contributing to zkSync hardhat tooling base repository.
zkSync Era Discord server: for questions and feedback.
Follow zkSync Era on Twitter
FAQs
Hardhat plugin that adds zkSync-specific capabilities to the Chaiassertion library, making your smart contract tests easy to write and read
The npm package @matterlabs/hardhat-zksync-chai-matchers receives a total of 7,769 weekly downloads. As such, @matterlabs/hardhat-zksync-chai-matchers popularity was classified as popular.
We found that @matterlabs/hardhat-zksync-chai-matchers demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.