Local Development Guide
Quick Start
1. Install Dependencies
From the repository root:
bash
npm installThis will install dependencies for all packages (contracts, dapp, website) using npm workspaces.
2. Run Website Locally
bash
npm run website:devWebsite will be available at: localhost:3001
3. Run DApp Locally
bash
npm run dapp:devDApp will be available at: localhost:3000
Detailed Setup
Prerequisites
- Node.js v18+
- npm v9+
- Git
Step-by-Step
Clone and Install
bashcd /path/to/CR8 npm installRun Website (Terminal 1)
bashnpm run website:dev # Opens on `localhost:3001`Run DApp (Terminal 2)
bashnpm run dapp:dev # Opens on `localhost:3000`
Environment Variables
DApp Environment Variables
Create packages/dapp/.env.local:
env
NEXT_PUBLIC_CHAIN_ID=11155111
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=your_walletconnect_project_id
NEXT_PUBLIC_CR8_TOKEN_ADDRESS=0xE808092649524be59337815D57cd2CFa457E2263
NEXT_PUBLIC_CR8_STAKING_ADDRESS=0x64352520ac1F83f1447cF72E42819010D2359537
NEXT_PUBLIC_TOKEN_VESTING_ADDRESS=0xCCcadaD8Bd3C32811e3dd194128d4E3A90e2f315
NEXT_PUBLIC_AGENT_DEPOSIT_ADDRESS=0xB3E801EAce32f616c67B0Ac29Cd0eb1677587C28Website Environment Variables
No environment variables needed for the website (static site).
Available Scripts
Root Level (from repo root)
bash
# Contracts
npm run contracts:compile # Compile smart contracts
npm run contracts:test # Run contract tests
npm run contracts:deploy:sepolia # Deploy to Sepolia
# DApp
npm run dapp:dev # Start DApp dev server (port 3000)
npm run dapp:build # Build DApp for production
npm run dapp:start # Start DApp production server
# Website
npm run website:dev # Start website dev server (port 3001)
npm run website:build # Build website for production
npm run website:start # Start website production serverPackage Level
You can also run commands from individual packages:
bash
# DApp
cd packages/dapp
npm run dev
npm run build
npm start
# Website
cd packages/website
npm run dev
npm run build
npm startDevelopment URLs
- Website:
localhost:3001 - DApp:
localhost:3000
Troubleshooting
Port Already in Use
If port 3000 or 3001 is already in use:
DApp:
bash
cd packages/dapp
# Edit package.json, change dev script to:
# "dev": "next dev -p 3002"
npm run devWebsite:
bash
cd packages/website
# Already configured for port 3001
# If needed, change to different port in package.jsonDependencies Not Found
bash
# Clean install
rm -rf node_modules packages/*/node_modules
rm -rf package-lock.json packages/*/package-lock.json
npm installBuild Errors
DApp:
bash
cd packages/dapp
npm run build
# Check for TypeScript errorsWebsite:
bash
cd packages/website
npm run build
# Check for build errorsEnvironment Variables Not Loading
- Make sure
.env.localis inpackages/dapp/directory - Restart the dev server after adding/changing env vars
- Check that variable names start with
NEXT_PUBLIC_for client-side access
Hot Reload
Both Next.js apps support hot module replacement (HMR):
- Changes to components/pages auto-reload
- No need to restart server for most changes
- Restart only needed for config changes
Testing Contracts Locally
bash
# Start local Hardhat node
cd packages/contracts
npx hardhat node
# In another terminal, deploy contracts
npm run deploy:local
# Update DApp .env.local with local contract addressesNext Steps
- ✅ Install dependencies:
npm install - ✅ Start website:
npm run website:dev - ✅ Start dapp:
npm run dapp:dev - ✅ Configure environment variables for dapp
- ✅ Connect wallet and test functionality
Production Builds
Build Website
bash
npm run website:build
# Output: packages/website/out/Build DApp
bash
npm run dapp:build
# Output: packages/dapp/.next/Need Help?
- Check package-specific READMEs:
packages/dapp/README.mdpackages/website/README.mdpackages/contracts/README.md