cd frontend
npm installVisit: https://www.freighter.app/
- Chrome/Brave: Install from Chrome Web Store
- Firefox: Install from Firefox Add-ons
- Create new account or import existing
- Switch to Testnet in Freighter settings
- Get free testnet XLM: https://laboratory.stellar.org/#account-creator
npm run devVisit: http://localhost:3000/wallet-demo
- Click "Connect Wallet"
- Select "Freighter"
- Approve connection in popup
- See your wallet connected!
- Freighter Integration: Full wallet connection support
- Persistent Sessions: Connection survives page reloads
- Network Switching: Toggle between Testnet and Mainnet
- Error Handling: User-friendly error messages
- TypeScript: Full type safety
- Transaction Support: Sign and submit transactions
- Demo Page: Working examples
frontend/
├── contexts/WalletContext.tsx ← Main wallet state
├── components/
│ ├── WalletButton.tsx ← Connect button
│ ├── NetworkSwitcher.tsx ← Network toggle
│ └── WalletInfo.tsx ← Wallet details
├── hooks/useWalletConnection.ts ← Easy-to-use hook
└── app/wallet-demo/ ← Demo & examples
Step 1: Wrap with provider
import { WalletProvider } from '@/contexts/WalletContext';
<WalletProvider>
<YourApp />
</WalletProvider>Step 2: Add UI components
import { WalletButton, NetworkSwitcher } from '@/components';
<header>
<NetworkSwitcher />
<WalletButton />
</header>Step 3: Use in components
import { useWallet } from '@/contexts/WalletContext';
function MyComponent() {
const { isConnected, publicKey } = useWallet();
return isConnected ? (
<p>Connected: {publicKey}</p>
) : (
<p>Connect your wallet</p>
);
}- Connect wallet successfully
- Refresh page - wallet stays connected
- Switch between Testnet and Mainnet
- Disconnect wallet
- Try connecting without Freighter (see error)
- Try with locked wallet (see error)
| Document | Purpose |
|---|---|
frontend/SETUP.md |
Detailed setup instructions |
frontend/WALLET_QUICKSTART.md |
Quick start guide |
frontend/WALLET_INTEGRATION.md |
Complete integration guide |
frontend/TESTING_CHECKLIST.md |
Testing procedures |
frontend/README_WALLET.md |
Main README |
Create .env.local:
NEXT_PUBLIC_STELLAR_NETWORK=testnet
NEXT_PUBLIC_HORIZON_URL=https://horizon-testnet.stellar.org"Freighter not installed" → Install Freighter extension and refresh page
"Please unlock your wallet" → Open Freighter and enter password
"Network mismatch" → Switch network in Freighter settings
Connection not persisting → Check localStorage is enabled in browser
const { isConnected } = useWallet();
if (!isConnected) {
return <p>Please connect wallet</p>;
}const { publicKey } = useWallet();
console.log('User wallet:', publicKey);import { useWalletConnection } from '@/hooks/useWalletConnection';
import { WalletType } from '@/types/wallet';
const { connectWallet } = useWalletConnection();
await connectWallet(WalletType.FREIGHTER);import { TransactionHelper } from '@/lib/stellar/transaction-helper';
const { publicKey, network } = useWallet();
const helper = new TransactionHelper(network);
const tx = await helper.buildPaymentTransaction(
publicKey!,
'GDESTINATION...',
'10.00'
);
const result = await helper.signAndSubmitWithFreighter(tx);
console.log('Success:', result.hash);- ✅ Complete setup above
- ✅ Test the demo page
- ✅ Integrate into your app
- ✅ Connect to payment flow
- ✅ Deploy to production
- Check
frontend/WALLET_INTEGRATION.mdfor detailed docs - Review
frontend/TESTING_CHECKLIST.mdfor testing - See
frontend/ARCHITECTURE.mdfor system design - Check Freighter docs: https://docs.freighter.app/
- ✅ Freighter wallet
- ✅ Persistent connection
- ✅ Network switching
- ✅ Error handling
- ✅ Loading states
- ✅ TypeScript
- ⏳ LOBSTR (coming soon)
- ⏳ WalletConnect (coming soon)
Ready to go! Start with the demo page and integrate into your app.
Issue: #33 - Implement Wallet Connection
Status: ✅ Complete