Understanding the directory structure of Mega CLI projects
mega init
without flags, you get a full-stack project with both smart contract and frontend development environments. Here’s an overview of the key directories and files:
foundry-app
directory contains your smart contract code organized in the Foundry standard structure:
forge-std
standard library.s.sol
suffixGmegaCounter.sol
included as an example.t.sol
suffixnext-app
directory contains a modern Next.js application:
Navbar.js
mega init --frontend
, you get a structure similar to the next-app
directory in the full-stack project:
mega init --foundry
, you get the standard Foundry structure:
src/
directory with a .sol
extensiontest/
directory with a .t.sol
extensionscript/
directory with a .s.sol
extensionpage.js
in the appropriate directory under src/app/
layout.js
in the appropriate directory under src/app/
src/components/
directorysrc/
directory and only test code in the test/
directory.t.sol
) and script files (.s.sol
)script/
directory for deployment scripts rather than ad-hoc deploymentsrc/constants/
directoryapp/gmega/
example to build your application’s functionality