New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@matterlabs/hardhat-zksync-chai-matchers

Package Overview
Dependencies
Maintainers
3
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@matterlabs/hardhat-zksync-chai-matchers

Hardhat plugin that adds zkSync-specific capabilities to the Chaiassertion library, making your smart contract tests easy to write and read

  • 1.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.8K
decreased by-1.31%
Maintainers
3
Weekly downloads
 
Created
Source

hardhat-zksync-chai-matchers 🚀

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."

Era Logo

⚠️ Version Compatibility Warning

Ensure you are using the correct version of the plugin with ethers:

  • For plugin version <1.0.0:

    • Compatible with ethers v5.
  • For plugin version ≥1.0.0:

    • Compatible with ethers v6 (⭐ Recommended)

📥 Installation

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

📖 Usage

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);

📝 Documentation

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.

🤝 Contributing

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.

🙌 Feedback, help and news

zkSync Era Discord server: for questions and feedback.
Follow zkSync Era on Twitter

Happy building!

Keywords

FAQs

Package last updated on 26 Feb 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc