A full-stack token presale platform built on Solana with real-time updates and admin dashboard.
- Smart Contract: Anchor program on Solana (Rust)
- REST API Backend Server: Express.js server for REST APIs
- Listener Server: Anchor Events Listener server with Socket.io for real-time events and writing events to DB
- Frontend: Next.js 14 with Solana wallet integration
- Database: AWS DynamoDB for event storage
- Connect Solana wallet (Phantom, Solflare)
- Deposit SOL to presale
- View deposit stats and estimated tokens
- Claim tokens when distribution is enabled
- View transaction history
- Real-time activity feed
- View presale statistics
- Enable token distribution
- View all participants
- Bulk distribute tokens
- Node.js 18+
- Yarn
- Solana CLI
- Anchor CLI
- AWS account with DynamoDB access
- Install dependencies:
cd backend
yarn install- Create
.envfile:
PORT=3001
FRONTEND_URL=http://localhost:3000
RPC_URL=https://api.devnet.solana.com
AWS_ACCESS_KEY_ID=your_key
AWS_SECRET_ACCESS_KEY=your_secret
AWS_REGION=us-east-1
SOLANA_KEYPAIR_PATH=~/.config/solana/id.json- Start the backend server:
yarn dev- Install dependencies:
cd frontend
yarn install- Create
.env.localfile:
NEXT_PUBLIC_API_URL=http://localhost:3001
NEXT_PUBLIC_SOCKET_URL=http://localhost:3001
NEXT_PUBLIC_PROGRAM_ID=HnQPtPdUZnYQpqX14QiP1CFY9x49hUyDCaaXUjRLH1JJ
NEXT_PUBLIC_MINT_ADDRESS=9PW5vownEEBguqy1WEcCH55vzyLb18428RdFagq7mLfe
NEXT_PUBLIC_ADMIN_WALLET=FSLqVntn9GbWGvd1WBvWS3aKQY8U8nvmbbBNffRDXnHD
NEXT_PUBLIC_RPC_URL=https://api.devnet.solana.com- Start the frontend:
yarn devThe event listener (app/listener.ts) listens to on-chain events and stores them in DynamoDB. It also emits Socket.io events for real-time updates.
To run the listener:
# Make sure the backend server is running first
tsx app/listener.tssolana-presale-token/
├── app/ # Backend utilities
│ ├── listener.ts # Event listener
│ ├── client.ts # Solana client
│ ├── eventStore.ts # DynamoDB event storage
│ └── db.ts # DynamoDB client
├── backend/ # Express.js server
│ ├── server.ts # Main server
│ ├── routes/ # API routes
│ └── services/ # Business logic
├── frontend/ # Next.js app
│ ├── app/ # Pages
│ ├── components/ # React components
│ ├── hooks/ # Custom hooks
│ └── lib/ # Utilities
└── programs/ # Solana program (Rust)
GET /api/user-stats/:wallet- Get user statisticsGET /api/presale-stats- Get presale statisticsGET /api/activities- Get recent activitiesGET /api/participants- Get all participants (admin)
deposit- New deposit eventdistribute- Token distribution eventenable_distribution- Distribution enabled eventinitialize_user- User initialization event
- Start backend:
cd backend && yarn dev - Start frontend:
cd frontend && yarn dev - Run listener:
tsx app/listener.ts
Backend:
cd backend
yarn build
yarn startFrontend:
cd frontend
yarn build
yarn start