What is the Playground?
The playground is a Docker Compose-based environment that runs:- All CoW Protocol services (orderbook, autopilot, driver, baseline solver)
- Forked blockchain via Anvil (Foundry)
- CoW Swap UI for testing
- CoW Explorer for transaction tracking
- PostgreSQL with migrations
- Otterscan block explorer
- Sourcify contract verification
- Grafana for monitoring
Currently only Fork mode is supported. The playground forks a real network (Mainnet by default) via Anvil. A clean local network mode is planned but not yet implemented.
Quick Start
Configure the environment
Copy the example environment file and edit it:Edit
.env and set your RPC URL:.env
Start the playground
Non-Linux users: Use
docker-compose.non-interactive.yml instead. Due to how Docker mounts work outside Linux, cargo-watch leads to very slow builds.Wait for services to stabilize
The first startup takes several minutes:
- Services compile (5-10 minutes)
- Contracts deploy
- Services sync
Configure your wallet
Add the local network to your wallet:
- RPC URL:
http://localhost:8545 - Chain ID:
1(or your forked network) - Currency: ETH
Import a test account
Use any of the first 10 accounts from the test mnemonic (see Test Accounts).Each account starts with 10,000 ETH.
- CoW Swap UI: http://localhost:8000
- CoW Explorer: http://localhost:8001
- Otterscan: http://localhost:8003
- Orderbook API: http://localhost:8080
- Database Admin: http://localhost:8082
- Grafana: http://localhost:3000
Available Services and Ports
| Component | Container Name | Host Port | Container Port | Tokio Console Port |
|---|---|---|---|---|
| Autopilot | autopilot | N/A | N/A | 6670 |
| Driver | driver | N/A | 80 | 6671 |
| Baseline Solver | baseline | N/A | 80 | 6672 |
| CoW Swap UI | cowswap | 8000 | 80 | N/A |
| CoW Explorer | cowexplorer | 8001 | 80 | N/A |
| Orderbook | orderbook | 8080 | 80 | 6669 |
| Anvil (RPC) | chain | 8545 | 8545 | N/A |
| PostgreSQL | postgres | 5432 | 5432 | N/A |
| Adminer | adminer | 8082 | 8080 | N/A |
| Grafana | grafana | 3000 | 3000 | N/A |
| Otterscan | otterscan | 8003 | 80 | N/A |
| Sourcify | sourcify | 5555 | 5555 | N/A |
| Sourcify DB | sourcify-db | N/A | 5432 | N/A |
Test Mnemonic and Accounts
All playground accounts derive from this test mnemonic:m/44'/60'/0'/0/
Private Keys (first 10 accounts):
Using CoW Swap UI Locally
Wrap some ETH
Before trading, you need WETH. Visit http://localhost:8000 and wrap some ETH.
EthFlow is not configured by default in the playground.
Make a swap
Select tokens and create a swap. The UI connects to your local orderbook at
localhost:8080.Track in Explorer
View your order at http://localhost:8001
Inspect transaction
Use Otterscan at http://localhost:8003 to see the full transaction trace.
Wallet Configuration
Rabby Wallet (Recommended)
Rabby provides the best experience:- Install Rabby Wallet
- Add custom network:
- RPC URL:
http://localhost:8545 - Chain ID:
1
- RPC URL:
- Import a test account (see Test Accounts)
- When connecting to CoW Swap, select “MetaMask” (Rabby intercepts this)
MetaMask
MetaMask doesn’t allow changing the Mainnet RPC in the UI. Use this workaround:- Open your browser’s developer console on the CoW Swap page
- Run this JavaScript:
- MetaMask will prompt to add the network
- Switch to “Local Network (Mainnet)”
- Import a test account
Debugging with tokio-console
The playground enables tokio-console for inspecting async runtime behavior.Enable tokio-console
Set the environment variable:
Tokio-console is only available in the playground. Production builds don’t include the overhead.
Connect to a service
Each service exposes a tokio-console port (see Services table):
- Active tasks
- Task states and durations
- Resource usage
- Async call stacks
Resetting the Playground
Reset when you need a clean state (e.g., after breaking changes or nonce issues).Stop and remove containers
- All containers
- All volumes (database state, blockchain state)
- Network configuration
Reset your wallet
Critical: Your wallet must be reset too, or you’ll have nonce mismatches.Rabby: Go to More → Clear pendingMetaMask: Follow these instructions
Switching Networks
Change the forked network:Live Reloading
The playground automatically recompiles and restarts services when you edit code. Linux users: Full live reload withdocker-compose.fork.yml
macOS/Windows users: Use docker-compose.non-interactive.yml for better performance (manual restart needed)
Manual Restart
Restart a specific service after code changes:Limiting Services
Run only specific services to save resources:Contract Verification with Sourcify
The playground includes a local Sourcify instance for contract verification.Sourcify Modes
Configure inplayground/.env:
A simple restart won’t work - you must recreate the container to re-read the
.env file.Verifying Contracts
Using Foundry:Using Otterscan
Otterscan is a powerful local block explorer integrated into the playground. Access: http://localhost:8003 Features:- Transaction traces with full call trees
- Decoded input data and logs
- Token transfers (ERC20, ERC721)
- Gas profiling
- Contract source code (via Sourcify)
- Click transaction link from CoW Swap or Explorer
- View the Trace tab
- Find where the revert occurred
- Check revert reason in trace output
- Pre-interactions
- Token approvals and transfers
- AMM interactions (Uniswap, etc.)
- Post-interactions
Advanced Configuration
Customize the playground by editingplayground/docker-compose.fork.yml:
- Change service ports
- Add environment variables
- Mount additional volumes
- Adjust resource limits
orderbook --helpautopilot --helpdriver --help
Troubleshooting
Services fail to start
Services fail to start
Check logs:Common issues:
- Port conflicts (another service using 8080, 8545, etc.)
- RPC connection issues
- Database migration failures
Compilation is very slow
Compilation is very slow
macOS/Windows users: Use the non-interactive compose file:All platforms: Allocate more memory to Docker (8GB+ recommended)
Trades don't settle
Trades don't settle
Check services are running:Check logs for errors:Ensure you have WETH, not just ETH
Wallet nonce errors
Wallet nonce errors
Reset wallet state:
- Rabby: More → Clear pending
- MetaMask: Settings → Advanced → Clear activity data
RPC connection errors
RPC connection errors
Check your RPC URL in Test RPC endpoint:
playground/.env:Next Steps
Testing Guide
Run tests against your changes
Contributing
Submit a pull request
Architecture
Understand the system
API Reference
Orderbook API documentation
