Skip to main content

Overview

The EVM smart contract workflow uses Foundry under the hood — the same toolchain used by Uniswap, OpenSea, and most serious Solidity teams. You get forge for compilation and testing, anvil for local development, and cast for chain interaction, all accessible through the AI chat without touching the terminal.

Project Structure

A standard Foundry project looks like this:
You can create this yourself or ask the AI:

foundry.toml

A minimal config:
If you’re using OpenZeppelin or other libraries, add remappings:

Compiling Contracts

Compile an Entire Project

If you have a foundry.toml:
This runs forge build on the entire project. Dependencies like OpenZeppelin are installed automatically.

Compile a Single Contract

For quick prototyping without a full project:

Compilation Output

After compilation you get:
  • Bytecode — the compiled contract ready for deployment
  • ABI — the interface definition for interacting with the contract
  • Bytecode file path — used by the deployment tool

OpenZeppelin Imports

Use the standard import format:
Dependencies are resolved automatically. No npm install, no forge install.

Testing Contracts

Tests use Foundry’s testing framework (forge-std). Write tests in Solidity:
Run tests:
You get pass/fail counts, gas usage per test, and full stack traces for failures.

Deploying Contracts

Behind the scenes:
  1. Starts Anvil if not already running
  2. Switches wallet to Local EVM
  3. Funds your account with test ETH
  4. Deploys the compiled bytecode
  5. Returns the contract address

To Testnet

Make sure you have testnet ETH from a faucet.

To Mainnet

Mainnet deployments cost real money. Contracts are immutable once deployed.

With Constructor Arguments

Arguments are ABI-encoded automatically based on the constructor signature.

Interacting with Deployed Contracts

Read Functions (Free, No Gas)

Write Functions (Costs Gas)

The AI handles ABI encoding. You provide the function name and arguments in a readable format.

Using Cast (Low-Level)

For advanced chain interaction:

Gas Estimation

Gas prices fluctuate with network demand. For non-urgent mainnet transactions, consider waiting for lower gas prices.

Security Auditing

This uses Aderyn to check for 90+ vulnerability patterns including reentrancy, access control issues, unchecked return values, and gas optimizations. For production contracts, also get a professional manual audit.

Common Patterns

Deployment Checklist

Before deploying to mainnet:
  1. All tests pass with no skipped tests
  2. Security audit is clean (no high/medium findings)
  3. Compiled with optimization enabled
  4. Constructor arguments verified
  5. Sufficient funds for gas
  6. Correct network selected

Troubleshooting

Common issues: missing semicolons, Solidity version mismatches (use ^0.8.24), import path errors (use @openzeppelin/contracts/... format), type mismatches.
Check: wallet connected, sufficient gas funds, constructor args match expected types, contract under 24KB size limit.
Verify: correct contract address, correct network, function name and arg types match ABI, require() conditions satisfied.
Check setUp() initialization, use vm.prank() for different addresses, use vm.expectRevert() before failing calls, run with verbose output.