A fully decentralized Twitter-like social media platform built on the Solana blockchain. Create profiles, post content, follow users, like posts, comment, and collaborate - all stored immutably on-chain with IPFS integration for media storage.
- Solana Integration: Fast, low-cost transactions
- Wallet Authentication: Phantom, Solflare, and other Solana wallets
- On-chain Storage: All user data and interactions stored on Solana
- IPFS Media Storage: Decentralized image and media hosting via Pinata
- Profile Creation: Custom usernames, display names, bios, and profile pictures
- Profile Updates: Edit your profile information anytime
- User Discovery: Browse and discover other users on the platform
- Post Creation: Text posts with optional image attachments
- Collaboration Posts: Co-author posts with other users
- Like System: Like and unlike posts with real-time updates
- Comment System: Comment on posts with threaded discussions
- Follow System: Follow/unfollow users to curate your feed
- Donation System: Support your favorite creators with SOL
- Platform Fees: Built-in monetization for platform sustainability
- Creator Analytics: Track followers, posts, and engagement
- Responsive Design: Mobile-first approach with Tailwind CSS
- Real-time Updates: Live interaction feedback
- Dark/Light Theme: Customizable user interface
- Smooth Animations: Enhanced user experience with transitions
- Framework: Next.js 14 with App Router
- Language: TypeScript
- Styling: Tailwind CSS
- State Management: React Hooks
- Wallet Integration: Solana Wallet Adapter
- Icons: React Icons (Font Awesome)
- Notifications: React Toastify
- Blockchain: Solana
- Smart Contract Language: Rust (Anchor Framework)
- RPC Provider: Solana RPC endpoints with Shyft fallback
- Storage: IPFS via Pinata for media files
- Package Manager: npm/yarn
- Linting: ESLint with TypeScript rules
- Code Formatting: Prettier
- Build Tool: Next.js built-in bundler
- Node.js 18+
- Rust 1.70+
- Solana CLI 1.16+
- Anchor CLI 0.28+
- Git
- Clone the repository
git clone https://github.com/yourusername/solana-twitter.git
cd solana-twitter- Install frontend dependencies
cd client
npm install- Install Rust and Solana tools
# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Install Solana CLI
sh -c "$(curl -sSfL https://release.solana.com/v1.16.0/install)"
# Install Anchor
npm install -g @coral-xyz/anchor-cli- Set up environment variables
cd client
cp .env.example .env.localCreate a .env.local file in the client directory with the following variables:
# ==========================================
# SOLANA BLOCKCHAIN CONFIGURATION
# ==========================================
# Network to connect to (devnet recommended for development)
NEXT_PUBLIC_CLUSTER=devnet
# Main RPC URL (fallback if no custom RPC specified)
NEXT_PUBLIC_RPC_URL=https://api.devnet.solana.com
# ==========================================
# IPFS STORAGE CONFIGURATION (REQUIRED)
# ==========================================
# Get these from https://pinata.cloud/
# Required for profile pictures and post images
PINATA_API_KEY=your_pinata_api_key_here
PINATA_SECRET_API_KEY=your_pinata_secret_api_key_here# ==========================================
# OPTIONAL: ENHANCED RPC PROVIDERS
# ==========================================
# Shyft API Key for enhanced devnet performance
# Get from https://shyft.to/ (free tier available)
# If not provided, falls back to default Solana devnet RPC
NEXT_PUBLIC_SHYFT_API_KEY=your_shyft_api_key_here
# Custom RPC URLs (override defaults)
NEXT_PUBLIC_MAINNET_RPC_URL=https://your-custom-mainnet-rpc.com
#Use Shyft Solana Rpc Provider to get your api key. Follow the link : https://dashboard.helius.dev/
NEXT_PUBLIC_DEVNET_RPC_URL=https://your-custom-devnet-rpc.com
# ==========================================
# DEVELOPMENT SETTINGS
# ==========================================
# Set to 'localhost' for local Solana test validator
# NEXT_PUBLIC_CLUSTER=localhost
# NEXT_PUBLIC_RPC_URL=http://127.0.0.1:8899- Visit Pinata Cloud
- Create a free account
- Go to API Keys section
- Generate new API key
- Copy
API KeyandAPI Secretto your.env.local
Free tier includes:
- 1 GB storage
- Sufficient for development and testing
- Visit Shyft
- Sign up for free account
- Get your API key from dashboard
- Add to
NEXT_PUBLIC_SHYFT_API_KEYin.env.local
Benefits:
- Enhanced devnet performance
- Better reliability
- Free tier: 100 requests/second
NEXT_PUBLIC_CLUSTER=devnet
NEXT_PUBLIC_RPC_URL=https://api.devnet.solana.comNEXT_PUBLIC_CLUSTER=localhost
NEXT_PUBLIC_RPC_URL=http://127.0.0.1:8899
# Start local test validator in another terminal
solana-test-validatorNEXT_PUBLIC_CLUSTER=mainnet-beta
NEXT_PUBLIC_RPC_URL=https://api.mainnet-beta.solana.com- Never commit
.env.localto version control - Use different API keys for development and production
- Rotate API keys regularly for production deployments
- Keep your
.env.examplefile updated for contributors
- Build the Solana program
cd programs/solana-twitter
anchor build- Deploy the program (optional for development)
anchor deploy- Start the development server
cd client
npm run devVisit http://localhost:3000 to see the application.
# Test devnet connection
curl -X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1, "method":"getHealth"}' \
https://api.devnet.solana.com# Check if all required vars are set
node -e "
const fs = require('fs');
const path = '.env.local';
if (fs.existsSync(path)) {
const content = fs.readFileSync(path, 'utf8');
console.log('✅ .env.local found');
console.log('Required vars present:');
console.log('PINATA_API_KEY:', content.includes('PINATA_API_KEY'));
console.log('PINATA_SECRET_API_KEY:', content.includes('PINATA_SECRET_API_KEY'));
console.log('NEXT_PUBLIC_CLUSTER:', content.includes('NEXT_PUBLIC_CLUSTER'));
} else {
console.log('❌ .env.local not found');
}
"npm run dev- Open http://localhost:3000
- Try connecting a wallet
- Verify network shows as "devnet" in wallet
# Error: "Failed to connect to RPC"
# Solution: Check network connectivity and RPC URL
# Test RPC endpoint
curl -X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1, "method":"getVersion"}' \
YOUR_RPC_URL# Error: "Failed to upload to IPFS"
# Solution: Verify Pinata API keys
# Test Pinata connection
curl -X GET \
-H "pinata_api_key: YOUR_API_KEY" \
-H "pinata_secret_api_key: YOUR_SECRET_KEY" \
https://api.pinata.cloud/data/testAuthentication- Ensure you're on the correct network (devnet/mainnet)
- Clear browser cache and wallet data
- Try different wallet (Phantom, Solflare, etc.)
Add this to your component for debugging:
// Add to any component for debugging
console.log('Environment Check:', {
cluster: process.env.NEXT_PUBLIC_CLUSTER,
rpcUrl: process.env.NEXT_PUBLIC_RPC_URL,
hasShyftKey: !!process.env.NEXT_PUBLIC_SHYFT_API_KEY,
hasPinataKeys: !!(process.env.PINATA_API_KEY && process.env.PINATA_SECRET_API_KEY)
})solana-twitter/
├── client/ # Next.js frontend application
│ ├── .env.example # Environment variables template
│ ├── .env.local # Your local environment (create this)
│ ├── src/
│ │ ├── app/ # Next.js 14 app router pages
│ │ │ ├── admin/ # Admin panel
│ │ │ ├── feed/ # Main feed page
│ │ │ ├── profile/ # Profile pages
│ │ │ └── layout.tsx # Root layout
│ │ ├── components/ # Reusable React components
│ │ │ ├── Comments.tsx # Comment system
│ │ │ ├── CreateProfile.tsx # Profile creation modal
│ │ │ ├── CreatePostModal.tsx # Post creation modal
│ │ │ ├── Header.tsx # Navigation header
│ │ │ ├── PostCard.tsx # Individual post component
│ │ │ └── ... # Other components
│ │ ├── services/ # Blockchain interaction services
│ │ │ └── blockchain.tsx # Main blockchain service
│ │ ├── utils/ # Utility functions
│ │ │ ├── interfaces.ts # TypeScript interfaces
│ │ │ ├── pinata.ts # IPFS integration
│ │ │ └── helpers.ts # Helper functions (RPC config)
│ │ └── styles/ # Global styles
│ ├── public/ # Static assets
│ └── package.json # Frontend dependencies
├── programs/ # Solana smart contracts
│ └── solana-twitter/
│ ├── src/
│ │ ├── instructions/ # Program instructions
│ │ │ ├── create_profile.rs
│ │ │ ├── create_post.rs
│ │ │ ├── like_post.rs
│ │ │ ├── follow_user.rs
│ │ │ └── ...
│ │ ├── states/ # Account state definitions
│ │ │ ├── user_profile.rs
│ │ │ ├── post.rs
│ │ │ ├── comment.rs
│ │ │ └── ...
│ │ ├── errors/ # Custom error definitions
│ │ ├── constants/ # Program constants
│ │ └── lib.rs # Main program entry
│ └── Cargo.toml # Rust dependencies
└── README.md # This file
We're specifically looking for UI/UX improvements! Here are priority areas:
- Mobile Responsiveness: Improve mobile layouts and touch interactions
- Dark Mode Implementation: Add proper dark/light theme toggle
- Loading States: Better loading animations and skeleton screens
- Error Boundaries: Implement proper error handling UI
- Accessibility: ARIA labels, keyboard navigation, screen reader support
- Search Functionality: Search users and posts
- Notification System: In-app notifications for likes, follows, comments
- Media Viewer: Image carousel and video player components
- Emoji Picker: Rich text editor with emoji support
- Trending Section: Display trending posts and users
- Performance Optimization: Code splitting, lazy loading
- PWA Features: Service worker, offline support
- Animation Library: Framer Motion integration
- Component Library: Storybook setup for component documentation
- Testing: Unit tests for components
- Fork the repository
- Create a feature branch
git checkout -b feature/your-feature-name
- Set up environment (follow instructions above)
- Make your changes
- Test thoroughly
- Commit with clear messages
git commit -m "feat: add dark mode toggle component" - Push and create a Pull Request
- TypeScript: Use strict typing, avoid
any - Components: Functional components with hooks
- Styling: Tailwind CSS classes, avoid inline styles
- File naming: PascalCase for components, camelCase for utilities
- Commit messages: Follow conventional commits format
# Run the development server
npm run dev
# Run linting
npm run lint
# Build for production (optional)
npm run build- Consistency: Follow existing design patterns
- Accessibility: Ensure WCAG 2.1 AA compliance
- Performance: Optimize images and animations
- Mobile-first: Design for mobile, enhance for desktop
- User Feedback: Provide clear feedback for all actions
- Main post display component
- Handles likes, comments, and delete functionality
- Integrates with blockchain for real-time updates
- Nested comment system
- Real-time comment loading and posting
- User interaction feedback
- Profile creation and editing
- IPFS image upload integration
- Form validation and error handling
- Main navigation
- Wallet connection status
- Mobile responsive menu
// Main program instructions
- initialize() // Initialize platform
- create_profile() // Create user profile
- update_profile() // Update user profile
- create_post() // Create new post
- delete_post() // Delete user's post
- like_post() // Like a post
- unlike_post() // Unlike a post
- create_comment() // Comment on post
- follow_user() // Follow another user
- unfollow_user() // Unfollow user
- donate_to_creator() // Send SOL to creator- UserProfile: User account data
- Post: Individual post data
- Comment: Comment data
- Follow: Follow relationship
- Like: Like relationship
- Donation: Donation record
- Mobile Menu: Needs better touch interactions
- Image Loading: Slow IPFS loading needs optimization
- Error Messages: More user-friendly error display
- Wallet Connection: Better connection state handling
- Real-time Updates: Implement WebSocket for live updates
- Solana Documentation
- Anchor Framework
- Next.js Documentation
- Tailwind CSS
- Solana Wallet Adapter
- Pinata IPFS Documentation
- Shyft RPC Documentation
- Discord: Join our community
- Telegram: Developer chat
- Twitter: @SolanaTwitter
This project is licensed under the MIT License - see the LICENSE file for details.
- Solana Foundation for the amazing blockchain infrastructure
- Anchor framework for simplifying Solana development
- Pinata for IPFS storage solutions
- Shyft for enhanced RPC services
- The open-source community for inspiration and tools
Ready to contribute? Check out our good first issues and join the decentralized social media revolution! 🚀
Made with ❤️ for Hacktoberfest 2024