Validium Docs
  • Overview
  • Connect to Validium
  • Start Coding 🚀
    • Quickstart
      • Overview
      • Deploy using Validium CLI
      • Deploy using Quickstart Repository
      • Deploy your first contract
      • Create an ERC20 token
  • Tooling
    • Block Explorers
    • Hardhat-Validium
      • Overview
      • Installation
      • Guides
        • Getting started
        • Migrating Hardhat project to Validium
        • Compiling non-inlinable libraries
      • Plugins
        • hardhat-zksync
        • hardhat-zksync-solc
        • hardhat-zksync-vyper
        • hardhat-zksync-deploy
        • hardhat-zksync-upgradable
        • hardhat-zksync-verify
        • hardhat-zksync-verify-vyper
        • hardhat-zksync-ethers
        • hardhat-zksync-node
        • Hardhat Community Plugins
    • Foundary
      • Overview
      • Installation
      • Getting Started
      • Migration Guide
        • Overview
        • Compilation
        • Deployment
        • Testing
  • Test and Debug
    • Getting Started
    • Docker L1 - L2 Nodes
    • In-Memory Node
    • Continuous Integration
    • Hardhat
    • Foundry
  • API Reference
    • Overview
    • Conventions
    • ZKs JSON-RPC API
    • Debug JSON-RPC API
    • Ethereum JSON-RPC API
    • PubSub JSON-RPC API
  • Concepts
    • Transaction Lifecycle
    • Blocks and Batches
    • Validium Network Fee Mechanism
    • Finality
    • System Upgrades
    • ZK Chains
    • Data Availability
      • Overview
      • Recreating L2 state from L1 pubdata
      • Validiums
    • Account Abstraction
    • L1 <-> L2 Communication
  • Components
    • Overview
    • Smart & System Contracts
      • Smart Contracts
      • System Contracts
    • Shared Bridges
    • Sequencer / Server
    • Validium Network EVM
      • Overview
      • Bootloader
      • Precompiles
      • Virtual Machine Specification
        • ZKsync Virtual Machine primer
        • VM Formal Specification
    • Prover
      • Overview
      • ZK Terminology
      • Running the Prover
      • Circuits
        • Overview
        • Circuit Testing
        • CodeDecommitter
        • DemuxLogQueue
        • ECRecover
        • KeccakRoundFunction
        • L1MessagesHasher
        • LogSorter
        • Main VM
        • RAMPermutation
        • Sha256RoundFunction
        • StorageApplication
        • Sorting and Deduplicating
          • Overview
          • SortDecommitments
          • StorageSorter
          • LogSorter
      • Boojum Gadgets
      • Boojum Function - `check_if_satisfied`
    • Compiler
      • Compiler Toolchain Overview
        • Compiler Toolchain Overview
        • Solidity Compiler
        • Vyper Compiler
        • LLVM Framework
      • Specification
        • Overview
        • Code Separation
        • System Contracts
        • Exception Handling
        • EVM Legacy Assembly Translator
        • Instructions
          • Instruction Reference
          • EVM
            • Native EVM Instructions
            • Arithmetic
            • Bitwise
            • Block
            • Call
            • Create
            • Environment
            • Logging
            • Logical
            • Memory
            • Return
            • Sha3
            • Stack
          • Extensions
            • Overview
            • Validium Network Extension Simulation (call)
            • Validium Network Extension Simulation (verbatim)
          • EVM Legacy Assembly
          • Yul
        • EraVM Binary Layout
    • Fee Withdrawer
    • Portal - Wallet + Bridge
    • Block Explorer
    • Transaction filtering
Powered by GitBook
On this page
  1. Tooling
  2. Foundary
  3. Migration Guide

Overview

Understand the key differences when migrating projects using foundry-zksync.


Getting started with Foundry on Validium requires a few key adjustments to accommodate the differences between Ethereum and Validium environments.

This guide will walk you through the essential steps for setting up your project, running tests, and configuring Foundry for Validium compatibility.

Validium Context

A forge test begins its execution in the standard EVM context, which is why compiling solc artifacts is necessary. However, during test execution, the context can switch over to Validium in several ways.

When switching to the Validium context, the following operations are performed:

  • All persisted_accounts storages are migrated to Validium storage.

  • Any EVM bytecode deployed under the migrated accounts is replaced by its zksolc variant.

  • Solidity globals such as block.number and address.balance will return Validium values even when the test begins in the EVM context.

  • The original EVM context (including the block environment) is preserved in case the test needs to switch back from Validium.

Switching to Validium

You can switch to the Validium context in the following ways:

CLI Flags

The --zksync flag compiles the sources for zksolc and automatically switches the test execution to the Validium context. This flag is a shorthand for enabling two specific flags:

  • --zk-startup: Switches to Validium on test startup.

  • --zk-compile: Compiles the sources using zksolc.

In the following sections, we will cover key areas for working with Foundry ZKsync:

  • Compiling: Learn the adjustments needed for zksolc to compile projects in Validium environments.

  • Deploying: Understand the process of deploying contracts on Validium.

  • Testing: Explore how to use forge test with the --zksync context, including test configurations and strategies to ensure correct contract behavior in Validium’s execution environment.

PreviousMigration GuideNextCompilation

Last updated 7 months ago