Prerequisites
Before you begin, ensure you have:- Node.js v16 or higher installed
- MongoDB running (local or Atlas)
- Access to TRON testnet (Nile)
- A text editor or IDE
Setup
Start the Server
Run the development server:You should see:The server will start on
http://localhost:3000Make Your First API Calls
Now let’s walk through a complete user flow: registration, order creation, and payment.Register a New User
Create a new user account. The system automatically generates a TRON wallet:Response:
Authentication tokens are automatically set as HttpOnly cookies. Save the user ID and wallet address for the next steps.
Fund Your Wallet
Before making purchases, you need TRX in your wallet. Get testnet TRX from the TRON Nile faucet:
- Visit Nile Testnet Faucet
- Enter your wallet address from the registration response
- Request testnet TRX (usually 10,000 TRX)
Create an Order
Create an order with selected products:Response:
Save the
orderId for the payment step. You can only have one pending order at a time.Process Payment
Pay for the order using TRX from your wallet:Response:
The payment is sent to the TRON blockchain. The transaction listener will automatically confirm it and update the order status to
completed within a few minutes.Real-time Notifications
The backend uses Socket.io for real-time transaction confirmations. Connect to receive instant updates:Explore the API
Your backend includes interactive API documentation powered by Swagger:- Browse all available endpoints
- Test API calls directly in your browser
- View request/response schemas
- Authenticate and try protected routes
Common Issues
Insufficient Balance Error
Insufficient Balance Error
If you receive an
INSUFFICIENT_BALANCE error, ensure:- You’ve requested testnet TRX from the Nile faucet
- The transaction has confirmed (wait 1-2 minutes)
- Your wallet has enough TRX to cover the order total plus network fees
Pending Order Exists
Pending Order Exists
You can only have one pending order at a time. Either:
- Complete the payment for your existing order
- Wait for it to expire (if implemented)
- Contact an admin to cancel it
Database Connection Failed
Database Connection Failed
Ensure MongoDB is running:
Next Steps
API Reference
Explore all available endpoints and their parameters
Authentication
Learn about JWT tokens, cookies, and role-based access
Admin Dashboard
Manage products, orders, and view analytics
Deployment
Deploy your backend to production