Skip to main content

Video Demo

Watch a full demonstration of Mega CLI in action:
This demo walks through setting up a starter project, working with accounts, deploying contracts, and more.

Prerequisites

Before you begin, make sure you have:
  • Installed Mega CLI globally (npm install -g megaeth-cli)
  • Set up Foundry using mega setup
  • Created a local account using mega account create (recommended)
If you haven’t completed these steps yet, see the Installation and Setup guide.

Creating Your First Project

Mega CLI makes it easy to set up a new project with all the necessary configuration for MegaETH.

Create a Full-Stack Project

This creates a full-stack project with both Foundry (for smart contracts) and Next.js (for frontend).
  • A Foundry environment configured for Mega testnet
  • A Next.js frontend with WalletConnect integration
  • Example smart contracts and frontend components
  • Configuration files and project structure

Start the Development Environment

Once your project is created, you can start the development environment:
This command starts both:
  • A local Anvil blockchain instance for development
  • The Next.js development server for the frontend
You can also start them individually (recommended):

Deploying Your First Contract

The starter project includes sample contracts you can deploy right away:
  1. First, compile your contracts:
  1. Then, deploy to the local development chain:
  1. Or, deploy to MegaETH testnet using your account:
For a mainnet deployment, select --network mainnet and use a funded mainnet account:
Before deploying to testnet, make sure you have test tokens. You can request them using:

Checking Account Balance

You can check the balance of your account or any address:

Next Steps

Now that you’ve created your first project and explored the basic features, you can:

Troubleshooting

If you encounter any issues:
  • Ensure Foundry is properly installed (mega setup --check)
  • Check that you’re using the latest version of Mega CLI
  • Confirm --network is set to testnet or mainnet for non-local operations
  • For testnet operations, confirm you have test tokens in your account