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
  • Usage
  • Limitations
  • Using libraries
  1. Components
  2. Compiler
  3. Compiler Toolchain Overview

Solidity Compiler

PreviousCompiler Toolchain OverviewNextVyper Compiler

Last updated 8 months ago


The compiler we provide as a part of our toolchain is called . It operates on IR and metadata received from the underlying compiler, which must be available in $PATH, or its path must be explicitly passed via the CLI (command-line interface).

To safeguard the security and efficiency of your application, always use the latest compiler version.

Usage

Make sure your machine satisfies the .

Using our compiler via the Hardhat plugin usually suffices. However, knowledge of its interface and I/O (input/output) methods are crucial for integration, debugging, or contribution purposes.

The CLI supports several I/O modes:

  1. Standard JSON.

  2. Combined JSON.

  3. Free-form output.

All three modes use the standard JSON solc interface internally. This reduces the complexity of the zksolc interface and facilitates testing.

Standard JSON

The zksolc standard JSON I/O workflow closely follows that of the official solc compiler. However, zksolc does not support some configuration settings which are only relevant to the EVM architecture.

Additional zkEVM data is supported by zksolc but is omitted when passed to solc:

  • settings/optimizer/mode: sets the optimization mode. Available values: 0, 1, 2, 3, s, z. The default setting is 3. See .

  • settings/optimizer/fallback_to_optimizing_for_size: tries to compile again in z mode if the bytecode is too large for zkEVM.

  • settings/optimizer/disable_system_request_memoization: disables the memoization of data received in requests to System Contracts.

Unsupported sections of the input JSON, ignored by zksolc:

  • sources/<file>/urls

  • sources/destructible

  • settings/stopAfter

  • settings/evmVersion

  • settings/debug

  • settings/metadata: for zkEVM you can only append keccak256 metadata hash to the bytecode.

  • settings/modelChecker

Additional zkEVM data inserted by zksolc:

  • long_version: the full solc version output.

  • zk_version: the zksolc version.

  • contract/hash: the hash of the zkEVM bytecode.

  • contract/factory_dependencies: bytecode hashes of contracts created in the current contract with CREATE.

Unsupported sections of the output JSON, ignored by zksolc:

  • contracts/<file>/<contract>/evm/bytecode: replaced with a JSON object with zkEVM build data.

  • contracts/<file>/<contract>/ewasm

Combined JSON

The zksolc standard JSON I/O workflow closely follows that of the official solc compiler. However, zksolc does not support some configuration settings which are only relevant to the EVM architecture.

Combined JSON is only an output format; there is no combined JSON input format. Instead, CLI arguments are used for configuration.

Additional zkEVM data, inserted by zksolc:

  • zk_version: the version of zksolc.

  • contract/factory_deps: bytecode hashes of contracts created by the current contract with CREATE.

Unsupported combined JSON flags, rejected by zksolc:

  • function-debug

  • function-debug-runtime

  • generated-sources

  • generated-sources-runtime

  • opcodes

  • srcmap

  • srcmap-runtime

Free-form output

This output format is utilized in Yul and LLVM IR compilation modes. These modes currently only support compiling a single file. Only --asm and --bin output flags are supported, so this mode can be useful for debugging and prototyping.

Limitations

Currently, Solidity versions as old as 0.4.12 are supported, although we strongly recommend using the latest supported revision of 0.8, as older versions contain known bugs and have limitations dictated by the absence of IR with sufficient level of abstraction over EVM.

Projects written in Solidity >=0.8 are compiled by default through the Yul pipeline, whereas those written in <=0.7 are compiled via EVM legacy assembly which is a less friendly IR due to its obfuscation of control-flow and call graphs. Due to this obfuscation, there are several limitations in ZKsync for contracts written in Solidity <=0.7:

  1. Recursion on the stack is not supported.

  2. Internal function pointers are not supported.

  3. Contract size and performance may be affected.

Using libraries

The usage of libraries in Solidity is supported in ZKsync Era with the following considerations:

  • If a Solidity library can be inlined (i.e. it only contains private or internal methods), it can be used without any additional configuration.

.

See the complete standard JSON data structures in .

.

For more information, see the complete combined JSON data structures in .

However, if a library contains at least one public or external method, it cannot be inlined and its address needs to be passed explicitly to the compiler; see .

zksolc
solc
system requirements
LLVM optimizer
More details here
the zksolc repository
More details here
the zksolc repository
compiling non-inlinable libraries