Skip to main content
Foundry is a fast, Solidity-native development toolkit for Ethereum smart contracts. It’s known for its blazing-fast speed and Solidity-centric approach, making it a great alternative to JavaScript-based tools like Hardhat.

Installation

Foundry installation is straightforward. Install using the official installer:
After running the installer, follow the instructions to re-open your terminal (or use source to reload environment variables), then run:
Running foundryup will automatically install the latest stable version of the precompiled binaries:
  • forge - Build, test, and deploy tool
  • cast - CLI for interacting with contracts
  • anvil - Local testnet node
  • chisel - Solidity REPL

Creating a New Project

Initialize a new Foundry project:
This creates a standard Foundry project structure with:
  • src/ - Your Solidity contracts
  • test/ - Your test files
  • script/ - Deployment scripts
  • foundry.toml - Configuration file

Configuring for MANTRA Chain

Update foundry.toml to configure MANTRA Chain networks:

Building Contracts

Build your contracts:

Testing

Write tests in Solidity and run them:

Deploying

Deploy to MANTRA Chain testnet:

Deployment walkthrough (legacy pattern)

If you prefer keeping deployment config in a .env file (handy for scripts/CI), you can use a pattern like:
Then:

Next Steps