Skip to content

Commit 51ed0f2

Browse files
add foundry details in AGENT.md
1 parent 3c91826 commit 51ed0f2

File tree

1 file changed

+58
-20
lines changed

1 file changed

+58
-20
lines changed

AGENTS.md

Lines changed: 58 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,32 @@ This file provides guidance to coding agents working in this repository.
44

55
## Project Overview
66

7-
Scaffold-ETH 2 (SE-2) is a starter kit for building dApps on Ethereum. It's a yarn monorepo with two main packages:
7+
Scaffold-ETH 2 (SE-2) is a starter kit for building dApps on Ethereum. It comes in **two flavors** based on the Solidity framework:
8+
9+
- **Hardhat flavor**: Uses `packages/hardhat` with hardhat-deploy plugin
10+
- **Foundry flavor**: Uses `packages/foundry` with Forge scripts
11+
12+
Both flavors share the same frontend package:
813

9-
- **packages/hardhat**: Solidity framework for smart contracts (Hardhat with hardhat-deploy)
1014
- **packages/nextjs**: React frontend (Next.js App Router, not Pages Router, RainbowKit, Wagmi, Viem, TypeScript, Tailwind CSS with DaisyUI)
1115

16+
### Detecting Which Flavor You're Using
17+
18+
Check which package exists in the repository:
19+
20+
- If `packages/hardhat` exists → **Hardhat flavor** (follow Hardhat instructions)
21+
- If `packages/foundry` exists → **Foundry flavor** (follow Foundry instructions)
22+
1223
## Common Commands
1324

25+
Commands work the same for both flavors unless noted otherwise:
26+
1427
```bash
1528
# Development workflow (run each in separate terminal)
16-
yarn chain # Start local Hardhat blockchain
29+
yarn chain # Start local blockchain (Hardhat or Anvil)
1730
yarn deploy # Deploy contracts to local network
1831
yarn start # Start Next.js frontend at http://localhost:3000
1932

20-
# Testing
21-
yarn test # Run all Hardhat tests
22-
yarn hardhat:test --grep "test name" # Run specific test
23-
2433
# Code quality
2534
yarn lint # Lint both packages
2635
yarn format # Format both packages
@@ -29,15 +38,11 @@ yarn format # Format both packages
2938
yarn next:build # Build frontend
3039
yarn compile # Compile Solidity contracts
3140

32-
# Type checking
33-
yarn hardhat:check-types
34-
yarn next:check-types
35-
36-
# Contract verification
41+
# Contract verification (works for both)
3742
yarn verify --network <network>
3843

39-
# Account management
40-
yarn account:generate # Generate new deployer account
44+
# Account management (works for both)
45+
yarn generate # Generate new deployer account
4146
yarn account:import # Import existing private key
4247
yarn account # View current account info
4348

@@ -51,9 +56,32 @@ yarn vercel:yolo --prod # for deployment of frontend
5156

5257
### Smart Contract Development
5358

54-
- Contracts go in `packages/hardhat/contracts/`
55-
- Deployment scripts in `packages/hardhat/deploy/` (uses hardhat-deploy plugin)
56-
- Tests in `packages/hardhat/test/`
59+
#### Hardhat Flavor
60+
61+
- Contracts: `packages/hardhat/contracts/`
62+
- Deployment scripts: `packages/hardhat/deploy/` (uses hardhat-deploy plugin)
63+
- Tests: `packages/hardhat/test/`
64+
- Config: `packages/hardhat/hardhat.config.ts`
65+
- Deploying specific contract:
66+
- If the deploy script has:
67+
```typescript
68+
// In packages/hardhat/deploy/01_deploy_my_contract.ts
69+
deployMyContract.tags = ["MyContract"];
70+
```
71+
- `yarn deploy --tags MyContract`
72+
73+
#### Foundry Flavor
74+
75+
- Contracts: `packages/foundry/contracts/`
76+
- Deployment scripts: `packages/foundry/script/` (uses custom deployment strategy)
77+
- Example: `packages/foundry/script/Deploy.s.sol` and `packages/foundry/script/DeployYourContract.s.sol`
78+
- Tests: `packages/foundry/test/`
79+
- Config: `packages/foundry/foundry.toml`
80+
- Deploying a specific contract:
81+
- Create a separate deployment script and run `yarn deploy --file DeployYourContract.s.sol`
82+
83+
#### Both Flavors
84+
5785
- After `yarn deploy`, ABIs are auto-generated to `packages/nextjs/contracts/deployedContracts.ts`
5886

5987
### Frontend Contract Interaction
@@ -131,9 +159,19 @@ SE-2 also provides other hooks to interact with blockchain data: `useScaffoldWat
131159
<button className="px-4 py-2 bg-blue-500 text-white rounded">Connect</button>
132160
```
133161

134-
### Configuration
162+
### Configure Target Network before deploying to testnet / mainnet.
163+
164+
#### Hardhat
165+
166+
Add networks in `packages/hardhat/hardhat.config.ts` if not present.
167+
168+
#### Foundry
169+
170+
Add RPC endpoints in `packages/foundry/foundry.toml` if not present.
171+
172+
#### NextJs
135173

136-
- `packages/nextjs/scaffold.config.ts`: Target networks, polling interval, API keys. Remember to decrease the polling interval for L2 chains.
174+
Add networks in `packages/nextjs/scaffold.config.ts` if not present. This file also contains configuration for polling interval, API keys. Remember to decrease the polling interval for L2 chains.
137175

138176
## Code Style Guide
139177

@@ -144,7 +182,7 @@ SE-2 also provides other hooks to interact with blockchain data: `useScaffoldWat
144182
| `UpperCamelCase` | class / interface / type / enum / decorator / type parameters / component functions in TSX / JSXElement type parameter |
145183
| `lowerCamelCase` | variable / parameter / function / property / module alias |
146184
| `CONSTANT_CASE` | constant / enum / global variables |
147-
| `snake_case` | for hardhat deploy files |
185+
| `snake_case` | for hardhat deploy files and foundry script files |
148186

149187
### Import Paths
150188

0 commit comments

Comments
 (0)