Prerequisites

Before installing the Mega CLI, ensure you have:
  • Node.js (v16 or higher)
  • npm, yarn, or pnpm package manager
  • Git (required for project initialization)

Installing the CLI

You can install the Mega CLI globally using your preferred package manager:
# Using npm
npm install -g megaeth-cli

# Using yarn
yarn global add megaeth-cli

# Using pnpm
pnpm add -g megaeth-cli
After installation, you can verify that the CLI is properly installed by running:
mega
If it was installed correctly, you’ll see something like this: Mega command result

Setting Up Foundry

Mega CLI necessarily requires Foundry for 3 of its 10 commands. The remaining 7 will work just fine without it. Foundry is a blazing fast, portable and modular toolkit for Ethereum application development. You can easily install it using the built-in setup command:
mega setup
This command will:
  • Check if Foundry is already installed
  • On Linux/macOS: Automatically install Foundry
  • On Windows: Guide you through the manual installation process
To only check if Foundry is installed without attempting installation:
mega setup --check

Manual Foundry Installation

If you prefer to install Foundry manually:
curl -L https://foundry.paradigm.xyz | bash
foundryup

Recommended: Setting Up a Local Account

For the optimal experience with MegaETH CLI, it’s recommended to set up a local account:
# Create a new account
mega account create

# Verify your account was created successfully
mega account list
When creating an account:
  1. You’ll be prompted to enter a name for your wallet (e.g., “dev”)
  2. You’ll need to set a password to encrypt your wallet
  3. The account will be stored in your local keystore
Your account can now be referenced in other commands using the --account flag.

Next Steps

Now that you have installed the MegaETH CLI and set up Foundry, you’re ready to: