Overview

Learn how to use Foundry ZKsync to build, test, and deploy smart contracts. Includes installation guides, and migration considerations.

Foundry ZKsync is a specialized fork of Foundry, tailored for ZKsync.

It extends Foundry's capabilities for Ethereum app development to support ZKsync, allowing for the compilation, deployment, testing, and interaction with smart contracts on ZKsync.

This section covers everything from installation to migration, ensuring that you’re equipped to begin using Foundry ZKsync effectively and efficiently. For a more in-depth review of Foundry ZKsync please refer to the Foundry ZKsync book on zksync.io.

Installation

Set up your development environment with Foundry and ZKsync, ensuring you're ready to start building and testing your projects.

Getting Started

Dive into the basics with a simple project setup, including running tests and deploying contracts on ZKsync.

Migration Guide

Step-by-step guide to migrating your existing projects to ZKsync using Foundry.

Testing

Learn best practices for testing your contracts with Foundry ZKsync

Status and Contribution

Foundry ZKsync is currently in its alpha stage, indicating ongoing development and potential for future enhancements. It is open-sourced, and contributions from the developer community are welcome. For more details and contributions, visit the GitHub repository.

Using Foundry with ZKsync

To work with ZKsync, you only need to make a few minor adjustments to your existing Foundry workflow. These changes ensure your smart contracts are fully compatible with ZKsync's zkEVM and reserved address space.

Differences

  1. Compilation:
    • Contracts are compiled using both solc and zksolc. Foundry ZKsync manages this automatically, but you should ensure the correct compiler versions are specified in your configuration (foundry.toml).
  2. Reserved Addresses:
    • ZKsync reserves addresses below 65536 for internal use. Ensure that any addresses you hardcode or use in tests are above this range.
    • You can configure fuzz testing to avoid generating reserved addresses using the no_zksync_reserved_addresses option.
  3. Fuzz Testing:
    • Fuzz tests can be configured to respect ZKsync's reserved address range. You can use the no_zksync_reserved_addresses = true option in your test configuration to avoid manual filtering of invalid addresses.
  4. Running Tests on ZKsync:
    • To target ZKsync in your tests, you can enable ZKsync-specific behaviors by adding --zksync to your forge commands or using vm.zkVm(true) in your test setup.

Foundry ZKsync simplifies developing and testing smart contracts on ZKsync with minimal changes to your workflow. With the installation and migration guides, you’ll be able to start building quickly while benefiting from ZKsync's scalability.

For more details or to get started, check out the Installation Guide or dive into the Getting Started section.


Made with ❤️ by the ZKsync Community