A comprehensive Solana blockchain indexing and MPC (Multi-Party Computation) service built with Rust. This project provides account indexing, user management, and threshold signature scheme (TSS) capabilities for Solana transactions.
This is a Rust workspace containing multiple crates:
- backend: REST API server for user management and Solana operations
- indexer: Yellowstone gRPC client for indexing Solana account data
- mpc1: Multi-party computation service for threshold signature schemes
- store: Shared library with database types and utilities
- User authentication (sign up, sign in)
- JWT-based authentication middleware
- Solana wallet operations:
- SOL balance checking
- Token balance checking
- SOL transfers
- Token swaps
- Transaction quotes
- Real-time Solana account indexing via Yellowstone gRPC
- Balance tracking for SOL and SPL tokens
- Account state monitoring
- PostgreSQL database integration
- Threshold signature scheme (TSS) implementation
- Multi-party key generation
- Aggregated transaction signing
- Support for SOL transfers and token swaps
- Secure key management
- Rust (latest stable version)
- PostgreSQL 16+
- Docker and Docker Compose (for local database setup)
- Solana CLI tools (optional, for development)
git clone <repository-url>
cd MCP_INDEXERStart the PostgreSQL database using Docker Compose:
docker compose up -dThis will:
- Start a PostgreSQL 16 container on port 5435
- Create the database
mpc5 - Run initialization scripts from
init/
Create a .env file in the project root with the following variables:
# Database
DATABASE_URL=postgresql://mympcuser:mympc@localhost:5435/mpc5
# gRPC Endpoint (for indexer)
GRPC_ENDPOINT=https://solana-rpc.parafi.tech:10443
X_TOKEN=your_token_here # Optional, for authenticated endpoints
# Backend Configuration
PORT=8085cargo build --releasecd backend
cargo runThe backend will start on http://127.0.0.1:8085
cd indexer
cargo runcd mpc1
cargo runThe MPC service will start on http://127.0.0.1:8080
POST /sign_up- Register a new userPOST /sign_in- Sign in and get JWT tokenGET /get_user- Get user information
GET /sol_balance- Get SOL balance for a walletGET /token_balance- Get token balance for a walletPOST /quote- Get swap quotePOST /swap- Execute token swapPOST /transfer- Transfer SOL or tokens
POST /generate- Generate a new keypair for a userGET /getuser- Get user keypair informationPOST /aggregate-keys- Aggregate multiple public keys
POST /agg-send-step1- First step of TSS signingPOST /agg-send-step2- Second step of TSS signingPOST /agg-send-step2-swap- Second step for swap transactionsPOST /aggregate-signatures-broadcast- Aggregate signatures and broadcast transactionPOST /aggregate-signatures-broadcast-swap- Aggregate signatures and broadcast swap transaction
The project uses PostgreSQL with the following main tables:
users: User accounts with authentication and wallet information- Account and balance tracking tables (managed by the indexer)
See init/init.sql for the initial schema.
cargo testcargo fmtcargo clippygraph TB
Frontend[Frontend]
Backend[Backend<br/>POST /signup<br/>POST /signin<br/>GET /user<br/>POST /quote<br/>POST /swap<br/>POST /send<br/>GET /balance/sol<br/>GET /balance/tokens]
Postgres[(Postgres)]
Indexer[Indexer]
MPC1[MPC 1]
MPC2[MPC 2]
MPC3[MPC 3]
DB1[(DB)]
DB2[(DB)]
DB3[(DB)]
SolanaRPC[Solana RPC]
Frontend -->|HTTP Requests| Backend
Backend -->|Database Operations| Postgres
Backend -->|TSS Operations| MPC1
Backend -->|TSS Operations| MPC2
Backend -->|TSS Operations| MPC3
Backend -->|Blockchain Operations| SolanaRPC
Indexer -->|Write Indexed Data| Postgres
MPC1 -->|Key Storage| DB1
MPC2 -->|Key Storage| DB2
MPC3 -->|Key Storage| DB3
style Frontend fill:#1e1e1e,stroke:#fff,stroke-width:2px,color:#fff
style Backend fill:#8b0000,stroke:#fff,stroke-width:2px,color:#fff
style Postgres fill:#336791,stroke:#fff,stroke-width:2px,color:#fff
style Indexer fill:#0066cc,stroke:#fff,stroke-width:2px,color:#fff
style MPC1 fill:#008000,stroke:#fff,stroke-width:2px,color:#fff
style MPC2 fill:#008000,stroke:#fff,stroke-width:2px,color:#fff
style MPC3 fill:#008000,stroke:#fff,stroke-width:2px,color:#fff
style SolanaRPC fill:#ff8c00,stroke:#fff,stroke-width:2px,color:#fff
style DB1 fill:#336791,stroke:#fff,stroke-width:2px,color:#fff
style DB2 fill:#336791,stroke:#fff,stroke-width:2px,color:#fff
style DB3 fill:#336791,stroke:#fff,stroke-width:2px,color:#fff
- Frontend: User interface that communicates with the Backend API
- Backend: REST API server handling authentication, user management, and Solana operations
- Postgres: Central database storing user data and indexed account information
- Indexer: Yellowstone gRPC service that monitors Solana blockchain and indexes account data
- MPC Services (MPC 1, 2, 3): Multi-party computation services for threshold signature schemes, each with its own database for key management
- Solana RPC: Solana blockchain RPC endpoint for on-chain operations (queries, transactions)
- JWT tokens for API authentication
- Password hashing with Argon2
- Secure key management in MPC service
- Database connection pooling
- Environment variable configuration for sensitive data
Key dependencies:
- actix-web: Web framework for backend API
- sqlx: Async PostgreSQL driver
- yellowstone-grpc: Solana gRPC client
- solana-sdk: Solana blockchain SDK
- multi-party-eddsa: Threshold signature implementation
- tokio: Async runtime