- System Overview
- High-Level Architecture
- Component Details
- Data Flow
- Technology Stack
- Deployment Architecture
TokenBound is a comprehensive implementation of Token Bound Accounts (TBAs) on the Stellar blockchain. It consists of multiple layers:
- Smart Contracts Layer: Soroban smart contracts managing TBA logic
- SDK Layer: TypeScript/JavaScript client SDK for interactions
- Frontend Layer: Web applications (tokenbound-client, soroban-client)
- Infrastructure: Docker, deployment scripts, and CI/CD
graph TB
subgraph "Client Layer"
WEB["🌐 Web Frontend"]
MOBILE["📱 Mobile Client"]
end
subgraph "Application Layer"
TOKENBOUND_CLIENT["TokenBound Client<br/>(Next.js)"]
SOROBAN_CLIENT["Soroban Client<br/>(Next.js + Event Platform)"]
end
subgraph "SDK Layer"
TOKENBOUND_SDK["TokenBound SDK<br/>(TypeScript)"]
SOROBAN_SDK["Soroban SDK<br/>(TypeScript)"]
end
subgraph "Blockchain Interaction"
HORIZON["Stellar Horizon API"]
RPC["Soroban RPC Server"]
FAILOVER["RPC Failover Manager"]
end
subgraph "Smart Contracts Layer"
TBA_REGISTRY["TBA Registry Contract"]
TBA_ACCOUNT["TBA Account Contract<br/>(Individual Accounts)"]
EVENT_MANAGER["Event Manager Contract"]
TICKET_FACTORY["Ticket Factory Contract"]
TICKET_NFT["Ticket NFT Contract<br/>(POAP)"]
VAULT["Vault Contract"]
end
subgraph "Infrastructure"
DOCKER["Docker Containers"]
DEPLOYMENT["Deployment Scripts"]
MONITORING["Monitoring Stack"]
end
WEB -->|interacts| TOKENBOUND_CLIENT
MOBILE -->|interacts| SOROBAN_CLIENT
TOKENBOUND_CLIENT -->|uses| TOKENBOUND_SDK
SOROBAN_CLIENT -->|uses| SOROBAN_SDK
TOKENBOUND_SDK -->|calls| FAILOVER
SOROBAN_SDK -->|calls| FAILOVER
FAILOVER -->|routes| RPC
FAILOVER -->|routes| HORIZON
RPC -->|submits| TBA_REGISTRY
RPC -->|submits| EVENT_MANAGER
EVENT_MANAGER -->|creates| TICKET_NFT
TICKET_NFT -->|links to| TBA_ACCOUNT
TBA_REGISTRY -->|manages| TBA_ACCOUNT
TBA_ACCOUNT -->|interacts| VAULT
VAULT -->|holds| TICKET_NFT
DOCKER -->|runs| RPC
DEPLOYMENT -->|deploys| TBA_REGISTRY
MONITORING -->|observes| DOCKER
style WEB fill:#4A90E2
style TOKENBOUND_CLIENT fill:#7B68EE
style SOROBAN_CLIENT fill:#7B68EE
style TOKENBOUND_SDK fill:#50C878
style SOROBAN_SDK fill:#50C878
style TBA_REGISTRY fill:#FF6B6B
style TBA_ACCOUNT fill:#FF8C42
style EVENT_MANAGER fill:#FF8C42
style TICKET_NFT fill:#FFB600
style VAULT fill:#00D9FF
- Location:
soroban-contract/contracts/tba_registry/ - Purpose: Factory and directory for TBA accounts
- Key Features:
- Deploys new TBA accounts for NFTs
- Maintains registry of all TBA accounts
- Manages account initialization
- Location:
soroban-contract/contracts/tba_account/ - Purpose: Individual token-bound smart account
- Key Features:
- Owned by current NFT holder
- Can hold and manage assets
- Implements custom account interface
- Location:
soroban-contract/contracts/event_manager/ - Purpose: Manages event lifecycle
- Key Features:
- Creates and manages events
- Controls event state transitions
- Links events to ticket contracts
- Location:
soroban-contract/contracts/poap_nft/ - Purpose: Event ticket representation (POAP-style)
- Key Features:
- ERC-20 compatible interface
- Event-specific metadata
- Transfer and approval handling
- Location:
soroban-contract/contracts/vault/ - Purpose: Asset custody and management
- Key Features:
- Holds and manages tokens
- Access control via TBA
- TypeScript SDK for Soroban contract interactions
- Components:
core.ts: Core SDK client, contract invocationdecoders.ts: Transaction result decodingtracer.ts: Request tracing and debuggingvalidation.ts: Input validation- Generated contract types from Rust ABIs
- Contract invocation (read/write operations)
- Transaction building and simulation
- Error handling and mapping
- Retry logic with configurable policies
- RPC failover support
- Next.js browser application
- Purpose: User portal for tokenbound features
- Features:
- Wallet connection
- Account management
- Asset transfers
- Next.js + Marketplace Application
- Purpose: Event platform and marketplace
- Features:
- Event creation and management
- Ticket marketplace
- Analytics dashboard
- Multi-language support (i18n)
docker-compose.yml: Local development environmentsoroban-contract/Dockerfile: Contract compilationclient/Dockerfile: Frontend containerization- Deployment scripts in
scripts/
- Health checks
- Gas estimation tracking
- Event logging
- Performance metrics
sequenceDiagram
participant User as User
participant Frontend as Frontend<br/>(soroban-client)
participant SDK as Soroban SDK
participant RPC as Soroban RPC
participant EventMgr as Event Manager<br/>Contract
User->>Frontend: Create Event
Frontend->>SDK: Build transaction
SDK->>SDK: Simulate transaction
SDK->>RPC: Submit transaction
RPC->>EventMgr: Execute create_event
EventMgr->>RPC: Event created
RPC-->>SDK: Transaction confirmation
SDK-->>Frontend: Success
Frontend-->>User: Event created
sequenceDiagram
participant User as User
participant Frontend as Frontend
participant SDK as Soroban SDK
participant RPC as Soroban RPC
participant TicketNFT as Ticket NFT<br/>Contract
participant TBARegistry as TBA Registry<br/>Contract
participant TBAAccount as TBA Account<br/>Contract
User->>Frontend: Purchase Ticket
Frontend->>SDK: Build purchase transaction
SDK->>RPC: Simulate & submit
RPC->>TicketNFT: Mint ticket NFT
TicketNFT->>TBARegistry: Request TBA creation
TBARegistry->>TBAAccount: Deploy TBA for NFT
TBAAccount->>TBAAccount: Initialize with NFT reference
TBAAccount-->>TicketNFT: TBA address
TicketNFT-->>RPC: Ticket minted + TBA linked
RPC-->>SDK: Confirmation
SDK-->>Frontend: Success
Frontend-->>User: Ticket received with TBA
- Network: Stellar
- Smart Contract Platform: Soroban
- Language: Rust
- Framework: Next.js (React)
- Styling: Tailwind CSS
- State Management: React Context (and optional Redux)
- Internationalization: next-intl
- Build Tool: Vite (for some packages)
- Language: TypeScript/JavaScript
- Testing: Jest
- HTTP Client: Fetch API
- RPC Client: @stellar/js-stellar-sdk
- Containerization: Docker
- Orchestration: Docker Compose
- CI/CD: GitHub Actions
- Code Quality: ESLint, Prettier, Rust fmt
graph LR
subgraph "Development"
DEVNET["Local Soroban<br/>Network"]
DOCKER_DEV["Docker Compose<br/>Dev Environment"]
end
subgraph "Staging"
TESTNET["Stellar<br/>Testnet"]
SOROBAN_TEST["Soroban<br/>Testnet RPC"]
end
subgraph "Production"
MAINNET["Stellar<br/>Mainnet"]
SOROBAN_PROD["Soroban<br/>Production RPC"]
end
subgraph "Frontend Hosting"
VERCEL["Vercel<br/>(Production)"]
STAGING_HOST["Staging Host"]
end
DOCKER_DEV -->|local development| DEVNET
DEVNET -->|test contracts| TESTNET
TESTNET -->|validate & deploy| MAINNET
TESTNET -->|RPC calls| SOROBAN_TEST
MAINNET -->|RPC calls| SOROBAN_PROD
SOROBAN_TEST -->|supports| STAGING_HOST
SOROBAN_PROD -->|supports| VERCEL
style DEVNET fill:#FFA500
style TESTNET fill:#FFD700
style MAINNET fill:#00AA00
style VERCEL fill:#000000,color:#fff
- Multiple RPC endpoints maintained
- Automatic failover on endpoint failure
- Health checks and retry logic
- Configurable endpoints per environment
- Contract events for state changes
- Event indexing for analytics
- Real-time updates via event feeds
- Separates contract complexity from frontend
- Provides type-safe interfaces
- Handles error mapping and transformation
- TBA Registry = Factory for creating TBA accounts
- Ticket Factory = Factory for creating ticket contracts
- ✅ ERC-20 compatibility layer in POAP NFT contract
- ✅ Gas estimation features for transaction planning
- ✅ Soroban v25 SDK support
- ✅ Enhanced error handling and diagnostics
- ✅ RPC failover manager with health checks
- ✅ Integration test suite for soroban-client
- ✅ Multi-language support (i18n) in web clients
- Contract Architecture - Detailed contract design
- Deployment Guide - Deployment procedures
- Contributing - Development guidelines
- API Reference - SDK API documentation