> **Can't find what you're looking for?** Use `search_docs` on the docs MCP server at `https://www.getfoundry.sh/api/mcp` to find what you need.
>
> **Have feedback?** Use `submit_feedback` on the same MCP server.

## Forge

Forge compiles, tests, and deploys Solidity smart contracts. It's the core development tool in the Foundry suite.

### Core workflows

[Build and test](/forge/testing): Compile contracts and run tests with traces.

[Clone verified contracts](/forge/cloning): Create a Forge project from explorer-verified source.

[Document contracts](/forge/documentation): Generate and publish an API site from Solidity NatSpec.

[Generate contract bindings](/forge/contract-bindings): Create typed Alloy bindings and Solidity JSON helpers.

[Advanced testing](/guides/invariant-testing): Fuzz, invariant, and fork-based testing workflows.

[Deploy and verify](/guides/deploying-contracts): Ship contracts with scripts and verify on explorers.

[Debug and optimize](/forge/gas-tracking): Trace failures and track gas usage.

### Key capabilities

| Feature | Description |
|---------|-------------|
| **Compilation** | Compile contracts with configurable Solidity versions and optimization |
| **Documentation** | Generate a Vocs API site from Solidity source and NatSpec comments |
| **Testing** | Write tests in Solidity with fuzzing, forking, and gas reporting |
| **Scripting** | Deploy and interact with contracts using Solidity scripts |
| **Verification** | Verify source code on Etherscan and other explorers |
| **Analysis** | Inspect bytecode, storage layouts, and gas usage |
| **Bindings** | Generate typed Alloy crates and Solidity JSON helpers |

### Common workflows

:::terminal
```bash [Build your project]
// [!include ~/snippets/output/hello_foundry/forge-build:command]
```

```ansi
// [!include ~/snippets/output/hello_foundry/forge-build:output]
```
:::

:::terminal
```bash [Run all tests]
// [!include ~/snippets/output/hello_foundry/forge-test:command]
```

```ansi
// [!include ~/snippets/output/hello_foundry/forge-test:output]
```
:::

:::terminal
```bash [Run tests with verbose output]
$ forge test -vvvv
```

```ansi
// [!include ~/snippets/output/cheatcodes/forge-test-vvvv:output]
```
:::

```bash [Deploy via script]
$ forge script script/Deploy.s.sol --broadcast --rpc-url $RPC_URL
```

```bash [Verify a deployed contract]
$ forge verify-contract $ADDRESS src/Counter.sol:Counter --etherscan-api-key $KEY
```

### Learn more

* [Building contracts](/forge/build) — Compilation, artifacts, and optimization
* [Cloning verified contracts](/forge/cloning) — Recreate a project from an address or proxy implementation
* [Contract documentation](/forge/documentation) — NatSpec, generated API pages, and publishing
* [Contract bindings](/forge/contract-bindings) — Alloy bindings and Solidity JSON helpers
* [Testing](/forge/testing) — Writing and running tests
* [Scripting](/forge/scripting) — Deployment and on-chain interactions
* [Debugging](/forge/debugging) — Traces, debugger, and troubleshooting
* [Gas tracking](/forge/gas-tracking) — Snapshots and reports
* [Linting](/forge/linting) — Code style enforcement
* [Reference](/reference/forge/forge) — Full CLI reference
