Skip to main content

mega compile

The compile command (also aliased as mega build) compiles Solidity contracts using Foundry’s Forge under the hood.

Usage

Options

Mega CLI passes all options directly to Forge. Here are some commonly used options:
The mega compile command supports all options available in forge build. See the Forge documentation for a complete list.

Description

This command compiles your Solidity contracts using Foundry’s Forge compiler. It’s a wrapper around forge build that ensures compatibility with the Mega CLI workflow while providing access to all of Forge’s powerful compilation options.

Examples

Basic compilation

Optimize contracts and show sizes

Watch for changes and recompile automatically

Force recompilation by clearing the cache

  • deploy - Deploy compiled contracts
  • setup - Ensure Foundry is properly installed