Quickstart
FTH Protocol - Quick Start Guide
Local development setup: prerequisites, services, builds, and verification.
Source: docs/QUICKSTART.md
Section
Overview
This guide will help you get the FTH Protocol staking platform up and running on your local machine in under 15 minutes.
Section
Prerequisites
Before you begin, ensure you have the following installed:
# Check versions
rustc --version # Should be 1.75+
cargo --version
node --version # Should be 20+
npm --version
docker --version
psql --version # PostgreSQL 15+
Installation Links
- Rust: https://rustup.rs/
- Node.js: https://nodejs.org/ (LTS version)
- Docker: https://www.docker.com/get-started
- PostgreSQL: https://www.postgresql.org/download/
Rust Toolchain Setup
# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Add wasm target
rustup target add wasm32-unknown-unknown
# Install cargo-contract for ink! contracts
cargo install cargo-contract --force
Section
Step 1: Clone Repository
git clone <repository-url>
cd "fth protocol"
Section
Step 2: Environment Configuration
# Copy environment template
cp .env.example .env
# Edit .env with your settings (optional for local dev)
# Default values work out of the box
Section
Step 3: Start Infrastructure Services
# Start PostgreSQL and Redis via Docker
docker-compose up -d postgres redis
# Wait for services to be healthy
docker-compose ps
Section
Step 4: Build Blockchain Runtime
# Navigate to blockchain directory
cd blockchain
# Build the runtime
cargo build --release
# This takes 10-15 minutes on first build
# Subsequent builds are much faster
Section
Step 5: Compile Smart Contracts
# FTH Stablecoin Contract
cd contracts/fth-stablecoin
cargo contract build --release
# stFTH Token Contract
cd ../st-fth-token
cargo contract build --release
# RWA Vault Contract
cd ../rwa-vault
cargo contract build --release
cd ../..
Section
Step 6: Setup Database
# Run migrations
cd backend/api
cargo sqlx database create
cargo sqlx migrate run
# Seed initial data (optional)
cargo run --bin seed
Section
Step 7: Start Blockchain Node
# In terminal 1
cd blockchain
cargo run --release -- --dev --tmp
You should see:
[Relaychain] ✨ Imported #1 (0x...)
[Relaychain] 💤 Idle (0 peers), best: #1
Section
Step 8: Start Backend API
# In terminal 2
cd backend/api
cargo run --release
You should see:
Starting FTH Protocol API Server
Connecting to database: postgresql://...
Database migrations complete
Starting HTTP server on 0.0.0.0:8080
Section
Step 9: Start Frontend
# In terminal 3
cd frontend
# Install dependencies
npm install
# Start development server
npm run dev
You should see:
ready - started server on 0.0.0.0:3000
Section
Step 10: Access the Platform
Open your browser and navigate to:
http://localhost:3000
You should see the FTH Protocol staking dashboard!
Section
Quick Test
Connect Wallet
- Click "Connect Wallet"
- Install Polkadot.js extension if needed
- Create or import an account
- Approve connection
Get Test Tokens
# Transfer tokens to your address
cd blockchain
cargo run --release -- transfer --to <YOUR_ADDRESS> --amount 1000000000000
Stake Tokens
- Navigate to "Stake" tab
- Enter amount:
100 FTH - Click "Stake Tokens"
- Approve transaction in wallet
- Wait for confirmation (~6 seconds)
You should now see:
- Your staked amount
- stFTH receipt tokens
- Current APY
Section
Troubleshooting
Port Already in Use
# Check what's using the port
lsof -i :3000 # or :8080, :9944
# Kill the process
kill -9 <PID>
Database Connection Error
# Ensure PostgreSQL is running
docker-compose ps postgres
# Check logs
docker-compose logs postgres
# Restart if needed
docker-compose restart postgres
Rust Build Errors
# Update Rust
rustup update stable
# Clean build artifacts
cargo clean
# Rebuild
cargo build --release
Frontend Build Errors
# Clear node_modules and reinstall
rm -rf node_modules package-lock.json
npm install
# Clear Next.js cache
rm -rf .next
npm run dev
Section
Development Workflow
Watch Mode (Auto-rebuild)
# Backend API
cd backend/api
cargo watch -x run
# Frontend
cd frontend
npm run dev
Running Tests
# Blockchain tests
cd blockchain
cargo test
# Smart contract tests
cd contracts/fth-stablecoin
cargo test
# Backend tests
cd backend/api
cargo test
# Frontend tests
cd frontend
npm test
Formatting
# Rust code
cargo fmt
# TypeScript code
cd frontend
npm run lint
npm run format
Section
Docker Compose (Alternative)
For a simpler setup, use Docker Compose for everything:
# Build all services
docker-compose build
# Start all services
docker-compose up
# Services will be available at:
# - Frontend: http://localhost:3000
# - API: http://localhost:8080
# - Blockchain RPC: http://localhost:9933
# - Blockchain WS: ws://localhost:9944
# - Grafana: http://localhost:3001
Section
Next Steps
1. Explore the Dashboard
- View staking statistics
- Check RWA portfolio
- Browse transaction history
- Monitor APY trends
2. Create RWA Investment (Governance)
# Using API
curl -X POST http://localhost:8080/api/v1/rwa/investments \
-H "Content-Type: application/json" \
-d '{
"investment_type": "USTreasury",
"principal": 1000000,
"yield_rate_bps": 450,
"maturity_days": 365
}'
3. Test Yield Distribution
# Manually trigger yield distribution (normally runs daily)
curl -X POST http://localhost:8080/api/v1/rwa/distribute-yield
4. Monitor Performance
Open Grafana dashboard:
http://localhost:3001
Username: admin
Password: admin_change_in_production
Section
Common Commands
# View logs
docker-compose logs -f
# Stop all services
docker-compose down
# Rebuild after code changes
docker-compose up --build
# Reset database
docker-compose down -v
docker-compose up -d postgres
cargo sqlx migrate run
# Check blockchain status
curl http://localhost:9933/health
# Check API health
curl http://localhost:8080/api/v1/health
Section
Getting Help
- Documentation: See
/docsdirectory - Issues: GitHub Issues
- Discord: Join our community
- Email: support@fth-protocol.io
Section
What's Next?
- Read the Architecture Overview
- Understand GENIUS Act Compliance
- Review API Documentation
- Explore Smart Contracts
Happy Staking! 🚀