A Telegram Mini App for mining TON coins and managing escrow transactions.
- Mining simulation for earning points
- Escrow system for secure TON transfers
- Referral system for earning bonuses
- TON wallet integration
- Shop to buy upgrades
- Clone the repository
- Install dependencies:
npm install - Start the development server:
npm run dev - The app will be available at http://localhost:3000
This application is configured to run on render.com as a Web Service (not a static site).
-
Make sure your repository includes:
server.js- Express server for production.env.production- Environment variables for productionrender.yaml- Configuration for render.com deployment
-
Connect your GitHub repository to render.com
-
Deploy with the following settings:
- Build Command:
npm install && npm run build - Start Command:
npm start - Node Version: 18.x or higher
- Build Command:
- Create a bot using @BotFather on Telegram
- Use
/newappcommand to create a Mini App for your bot - Set the Web App URL to your render.com deployment URL
- Configure bot settings properly for inline mode if needed
This error typically occurs when:
-
WebApp Script Loading: Ensure the Telegram WebApp script is loaded properly:
<script src="https://telegram.org/js/telegram-web-app.js"></script>
-
CORS Issues: Ensure your server has proper CORS headers:
Access-Control-Allow-Origin: * Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization -
Telegram Launch Context: The app must be launched within Telegram to receive the necessary
initData. -
X-Frame-Options: Ensure appropriate X-Frame-Options header:
X-Frame-Options: ALLOW-FROM https://web.telegram.org -
Debug Mode: Add
?tgWebAppDebug=1parameter to the URL when testing in Telegram. -
Check Console Logs: The app includes comprehensive logging to help diagnose issues.
-
Debug Page: Access the built-in debug page at
/debugto see detailed information about the Telegram WebApp environment. -
URL Debug Parameter: Add
?tgWebAppDebug=1to your app's URL to enable the floating debug panel, which shows real-time Telegram WebApp information. -
Keyboard Button Launch: When launching from a keyboard button or inline mode (not from a direct link), note that the
initDatamay be empty. In this case, the app uses the user information frominitDataUnsafefor authentication. -
Bot Settings Check: Verify in BotFather that:
- Inline mode is enabled (if launching from inline queries)
- Menu button is properly configured (if launching from bot menu)
- Domain is allowed in the bot settings
-
initData Structure: For debugging, know that the initData contains:
query_id: Unique ID for the queryuser: Telegram user dataauth_date: Authentication timestamphash: Hash signature for validation
-
Common Errors:
- "Telegram WebApp is not available" - Not launching from Telegram
- "Missing Telegram authentication" - initData not provided or invalid
- "WebApp.ready() failed" - Error in WebApp initialization
-
Testing in Development: Use the mock Telegram login functionality in development to simulate Telegram data.
This server error occurs when:
- The server tries to send multiple responses to a single request
- Express routes are not properly configured for SPA routing
- Middleware is not correctly handling response headers
The provided server.js file has been configured to avoid these issues by:
- Checking
res.headersSentbefore sending responses - Properly configuring static file serving and SPA fallback routes
- Adding error handling middleware
The app interacts with a backend API at https://qserver-ii0a.onrender.com/api. Endpoints include:
/api/auth/check_and_create_user- Login or create users/api/auth/get_referrals- Get referral information/api/game/...- Mining-related endpoints/api/escrow/...- Escrow transaction endpoints/api/shop/...- Shop and inventory endpoints
- React.js
- Express.js (production server)
- Webpack
- Telegram Mini App API
- TON Connect (for wallet integration)
- Render.com (hosting)