Skip to content

Stellar-Wave-Labs/stellar-connect

Repository files navigation

🌌 StellarConnect

License: MIT TypeScript React Stellar Vite PRs Welcome Build

StellarConnect is a production-ready, chain-agnostic wallet integration dApp built with React 19 and TypeScript. It connects users to the Stellar Network through a beautiful, responsive interface that abstracts all blockchain complexity behind a clean provider interface.

Originally built for the Base (EVM) ecosystem, StellarConnect was fully migrated to Stellar, trimming the bundle from 2.5 MB β†’ 1.02 MB and replacing EVM-specific tooling with a leaner, purpose-built Stellar stack.


πŸ“Έ Preview

Connect your Stellar wallet (Freighter, xBull, Rabet), view real-time balances, send assets, manage trustlines, claim testnet XLM via Friendbot, and invoke Soroban smart contracts β€” all in one UI.


✨ Feature Set

Feature Description
πŸ”— Multi-Wallet Support Connects via Freighter, xBull, and Rabet using the Stellar Wallets Kit
πŸ’° Real-time Balances Fetches native XLM + all custom trustline tokens from Horizon
πŸ“€ Send Transactions Builds, signs, and submits Stellar payments for any asset
πŸͺ™ Trustline Manager Establishes trustlines for custom Stellar assets (with testnet USDC preset)
πŸ“‹ Recent Payments Feed Displays last 10 on-chain operations with StellarExpert explorer links
🚰 Friendbot Faucet One-click testnet XLM funding via Stellar's Friendbot API
πŸ€– Soroban Smart Contracts Reads and increments a counter value on a deployed WASM contract via Soroban RPC
🎨 Premium UI Fluid animations (Framer Motion + GSAP), dark mode, glassmorphism cards
🌐 Testnet / Mainnet Toggle Single env variable switches the entire network stack

πŸ—οΈ Architecture

StellarConnect is built around a strict ChainProvider interface. React components never import chain-specific SDKs β€” they only interact with useWallet(), making the UI fully portable.

src/
β”œβ”€β”€ chain/
β”‚   β”œβ”€β”€ types.ts              # ChainProvider interface + shared types
β”‚   └── stellar/
β”‚       β”œβ”€β”€ horizon.ts        # Horizon API + Soroban RPC helpers
β”‚       β”œβ”€β”€ network.ts        # Network passphrase / label constants
β”‚       └── provider.ts       # StellarProvider class (implements ChainProvider)
β”œβ”€β”€ hooks/
β”‚   └── useWallet.ts          # Central hook β€” connects UI to the active provider
β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ WalletInfo.tsx         # Main dashboard card
β”‚   β”œβ”€β”€ Hero.tsx               # Landing section
β”‚   β”œβ”€β”€ Layout.tsx             # Page shell
β”‚   β”œβ”€β”€ Features.tsx           # Marketing feature cards
β”‚   β”œβ”€β”€ ThemeToggle.tsx        # Dark/light mode switcher
β”‚   └── AnimatedBackground.tsx # Particle / bubble background effects
β”œβ”€β”€ contexts/                  # React context providers
β”œβ”€β”€ providers/                 # App-level provider wrappers
β”œβ”€β”€ utils/
β”‚   └── address.ts             # Stellar address validation utility
└── index.css                  # Design tokens + global styles

Data Flow

graph TD
    A["React UI Components"] -->|consumes| B("useWallet() Hook")
    B -->|reads VITE_CHAIN| C{Provider Selection}
    C -->|stellar| D[StellarProvider]
    D --> E["@creit.tech/stellar-wallets-kit"]
    D --> F["Horizon REST API"]
    D --> G["Soroban RPC Server"]
    F -->|payments / trustlines / XLM| D
    G -->|WASM contract read/write| D
Loading

βš™οΈ Tech Stack

Layer Technology
Framework React 19 + TypeScript 5.9
Build Tool Vite 7
Stellar SDK @stellar/stellar-sdk v16
Wallet Kit @creit.tech/stellar-wallets-kit v2.5
Animations Framer Motion + GSAP 3
UI Components Geist UI + Lucide Icons
Styling Tailwind CSS v4 + custom design tokens
Linting ESLint 9 + TypeScript-ESLint

πŸš€ Quick Start

Prerequisites

  • Node.js v20 or higher
  • npm v10 or higher
  • A Stellar-compatible browser wallet: Freighter, xBull, or Rabet

Installation

# 1. Clone the repository
git clone https://github.com/<your-org>/stellar-connect.git
cd stellar-connect

# 2. Install dependencies
npm install

# 3. Configure environment
cp .env.example .env

# 4. Start the development server
npm run dev

Open http://localhost:5173 in your browser.


πŸ”§ Environment Configuration

Create a .env file (or copy .env.example) in the project root:

# Active blockchain chain (currently only 'stellar' is supported)
VITE_CHAIN=stellar

# Stellar network β€” 'testnet' for development, 'mainnet' for production
VITE_STELLAR_NETWORK=testnet
Variable Values Default Description
VITE_CHAIN stellar stellar Selects the active ChainProvider implementation
VITE_STELLAR_NETWORK testnet | mainnet testnet Targets Stellar Testnet or Mainnet Horizon endpoints

Note: Switching to mainnet automatically changes the Horizon endpoint, network passphrase, and Soroban RPC endpoint. Never use a funded mainnet wallet with an untested contract ID.


πŸ“– Using the App

1. Connect Your Wallet

Click "Connect Wallet" in the hero section. The Stellar Wallets Kit modal will appear, letting you choose Freighter, xBull, or Rabet.

2. View Balances

Once connected, the dashboard displays:

  • Your wallet address (with copy + StellarExpert links)
  • Native XLM balance
  • All custom token balances (established via trustlines)
  • Current network label

3. Friendbot Faucet (Testnet Only)

Click the "Friendbot" button on the balances card to instantly fund your testnet wallet with 10,000 XLM. The balance auto-refreshes after a 2-second ledger ingestion delay.

4. Send Assets

Fill in a recipient Stellar address (G...) and an amount. If you hold multiple assets, a dropdown lets you select which to send. Click "Send Transaction" and sign in your wallet.

5. Add Custom Token (Trustlines)

Enter an Asset Code (e.g., USDC) and Issuer Address, then click "Establish Trustline". Use the quick-fill "+ USDC (Testnet)" preset to avoid manual copy-pasting of issuer addresses.

6. Recent Payments

The payments table auto-populates with your last 10 operations:

  • 🟒 Received β€” incoming payments (green)
  • πŸ”΄ Sent β€” outgoing payments (red)
  • 🟑 Create Account β€” account creation ops (amber)

Each row links directly to StellarExpert for full transaction details.

7. Soroban Smart Contract Counter

The "Soroban WASM Smart Contract Counter" card lets you interact with an on-chain counter contract:

  • Fetch Value β€” Simulates a read-only call to get the current counter integer
  • Increment β€” Builds, simulates, signs, submits, and polls a WASM increment transaction

The default Contract ID is pre-populated with a testnet counter contract for immediate demonstration.


πŸ”Œ ChainProvider Interface

All blockchain logic is isolated behind this interface in src/chain/types.ts:

export interface ChainProvider {
  connect(): Promise<{ address: string }>;
  disconnect(): Promise<void>;
  getAddress(): string | null;
  getBalances(address: string): Promise<BalanceInfo[]>;
  getNetworkLabel(): string;
  isConnected(): boolean;
  sendTransaction(to: string, amount: string, assetCode?: string, assetIssuer?: string): Promise<{ hash: string }>;
  getRecentPayments(address: string): Promise<PaymentRecord[]>;
  addTrustline(assetCode: string, assetIssuer: string): Promise<{ hash: string }>;
  fundAccount(address: string): Promise<boolean>;
  getContractValue(contractId: string): Promise<number>;
  incrementContractValue(contractId: string): Promise<{ hash: string }>;
}

To add support for a new blockchain (e.g., Solana), create a new class that implements this interface and swap it in via the VITE_CHAIN environment variable. No UI changes required.


πŸ“œ Available Scripts

# Start the development server with HMR
npm run dev

# Type-check + build the production bundle
npm run build

# Run ESLint across all source files
npm run lint

# Preview the production build locally
npm run preview

πŸ—‚οΈ Key Files Reference

File Purpose
src/chain/types.ts ChainProvider interface + BalanceInfo / PaymentRecord types
src/chain/stellar/provider.ts Full Stellar implementation: connect, balances, payments, trustlines, Soroban
src/chain/stellar/horizon.ts Horizon REST client, Friendbot helper, Soroban RPC server instance
src/chain/stellar/network.ts Network constants and passphrase resolution
src/hooks/useWallet.ts Reactive hook exposing all provider actions to UI
src/components/WalletInfo.tsx Main dashboard component (balances, send, trustlines, Soroban, payments)
src/utils/address.ts Stellar G... address validation regex

🀝 Contributing

We warmly welcome contributions from the community! Please read our full Contributing Guide before opening a pull request.

Quick Contribution Summary

  1. Fork the repository and clone locally
  2. Branch using the naming convention:
    • feat/feature-name β€” new features
    • fix/bug-description β€” bug fixes
    • docs/doc-name β€” documentation
    • refactor/scope β€” internal improvements
  3. Commit following Conventional Commits:
    feat: add soroban contract read support
    fix(ui): correct overflow on mobile wallet card
    docs: update environment setup instructions
    
  4. Ensure npm run lint and npm run build pass cleanly
  5. Open a Pull Request against the dev branch and fill out the PR template

Good First Issues

  • Adding support for a new Stellar wallet (e.g., Lobstr, Solar)
  • Improving error messages and UX for failed transactions
  • Adding unit tests for the useWallet hook
  • Writing E2E tests with Playwright

πŸ›‘οΈ Security

  • Never commit .env or .env.local files β€” they are gitignored by default
  • All transaction signing happens inside your wallet extension β€” private keys never touch the app
  • The Soroban RPC endpoint is public testnet only; production deployments should use an authenticated RPC provider
  • Please report security vulnerabilities privately to the maintainers rather than opening a public issue

πŸ“„ License

This project is licensed under the MIT License β€” see the LICENSE file for full details.


πŸ™ Acknowledgements

About

No description, website, or topics provided.

Resources

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages