Overview
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.
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
- Compilation:
- Contracts are compiled using both
solc
andzksolc
. Foundry ZKsync manages this automatically, but you should ensure the correct compiler versions are specified in your configuration (foundry.toml
).
- Contracts are compiled using both
- 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.
- ZKsync reserves addresses below
- 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.
- Fuzz tests can be configured to respect ZKsync's reserved address range.
You can use the
- Running Tests on ZKsync:
- To target ZKsync in your tests, you can enable ZKsync-specific behaviors by adding
--zksync
to yourforge
commands or usingvm.zkVm(true)
in your test setup.
- To target ZKsync in your tests, you can enable ZKsync-specific behaviors by adding
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.