# CrossChain Connect Protocol
## Overview
CrossChain Connect is a universal protocol for connecting multi-chain wallets to decentralized applications. Unlike WalletConnect (EVM-only), it supports Bitcoin, Monero, and EVM chains with a unified approach.
## Message Types
All communication is JSON-based with the following structure:
### ConnectionRequest
```json
{
"type": "ConnectionRequest",
"session_id": "550e8400-e29b-41d4-a716-446655440000",
"timestamp": "2025-01-15T10:30:00Z",
"dapp_name": "MyDApp",
"dapp_url": "https://mydapp.com",
"requested_chains": ["ethereum", "bsc", "bitcoin"]
}
```
### ConnectionResponse
```json
{
"type": "ConnectionResponse",
"session_id": "550e8400-e29b-41d4-a716-446655440000",
"selected_chain": "ethereum",
"wallet_address": "0x742d35Cc6634C0532925a3b844Bc9e7595f42553"
}
```
### TransactionRequest
```json
{
"type": "TransactionRequest",
"session_id": "550e8400-e29b-41d4-a716-446655440000",
"to": "0x...",
"value": "1000000000000000000",
"data": "0x..."
}
```
### SignMessageRequest
```json
{
"type": "SignMessageRequest",
"session_id": "550e8400-e29b-41d4-a716-446655440000",
"message": "Sign this message to verify ownership"
}
```
## Supported Chains
```
EVM Chains:
- ethereum (Chain ID: 1)
- bsc (Chain ID: 56)
- polygon (Chain ID: 137)
- arbitrum (Chain ID: 42161)
- optimism (Chain ID: 10)
Non-EVM:
- bitcoin (Bitcoin Mainnet)
- bitcoin-testnet
- monero (Monero Mainnet)
- monero-stagenet
- monero-testnet
```
## Connection Flow
1. **dApp** sends ConnectionRequest with requested chains
2. **Wallet** generates session and QR code
3. **User** approves on wallet app
4. **Wallet** sends ConnectionResponse with selected chain & address
5. **dApp** can now request transactions/signatures for that session
## Session Management
- Sessions expire after 15 minutes by default
- Each session has unique ID (UUID v4)
- Session token is cryptographically generated
## Security
### Message Authentication
- HMAC-SHA256 for message integrity
- EIP-191 for Ethereum message signing
- Chain-specific signing for non-EVM
### Private Keys
- Private keys never leave the wallet
- Only signatures transmitted
- Public keys used for verification
## QR Code Format
```
crosschain://connect?session_id=<UUID>&dapp_url=<URL>
```
Example PNG size: 200x200 pixels
## Error Handling
```json
{
"type": "Error",
"error": "Invalid chain requested"
}
```
## Implementation Notes
- All timestamps in UTC ISO8601
- Addresses must be validated per-chain
- Amount values are in smallest unit (wei for EVM, satoshi for BTC)
- Nonces prevent replay attacks