A TypeScript backend service for launching meme tokens with PancakeSwap integration, based on the Four.Meme platform.
- Token Creation API: Create meme tokens with automatic PancakeSwap integration
- Four.Meme Integration: Authenticate and interact with Four.Meme API
- Blockchain Integration: Handle BSC transactions and smart contract interactions
- Rate Limiting: Built-in rate limiting for API protection
- Error Handling: Comprehensive error handling and logging
- Health Checks: Health, readiness, and liveness endpoints
- Node.js 18+
- npm or yarn
- BSC wallet with private key
- Access to Four.Meme API
-
Clone and navigate to backend directory:
cd backend -
Install dependencies:
npm install
-
Set up environment variables:
cp env.example .env
Edit
.envwith your configuration:# Server Configuration PORT=3001 NODE_ENV=development # Blockchain Configuration BSC_RPC_URL=https://bsc-dataseed.binance.org/ PRIVATE_KEY=your_private_key_here WALLET_ADDRESS=your_wallet_address_here # Four.Meme API Configuration FOUR_MEME_API_URL=https://four.meme/meme-api TOKEN_MANAGER_CONTRACT_ADDRESS=0x5c952063c7fc8610FFDB798152D69F0B9550762b WBNB_ADDRESS=0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c
npm run devnpm run build
npm startThe server will start on http://localhost:3001 (or your configured PORT).
GET /api/health- Health checkGET /api/health/ready- Readiness checkGET /api/health/live- Liveness check
POST /api/token/launch- Launch a new tokenGET /api/token/status/:txHash- Get transaction statusGET /api/token/balance- Get wallet balancePOST /api/token/validate- Validate token configuration
POST /api/token/launch
Content-Type: application/json
{
"name": "My Meme Token",
"symbol": "MMT",
"description": "A great meme token",
"imgUrl": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...",
"tag": "Meme",
"tradingFee": 0.02, // Fixed 2% (1% creator + 1% platform)
"presale": 0, // Fixed 0%
"totalSupply": 1000000000, // Fixed 1B tokens
"saleRate": 0.8, // Fixed 80%
"reserveRate": 0 // Fixed 0%
}- Authentication: Authenticate with Four.Meme API using wallet signature
- Token Info: Get token creation parameters from Four.Meme
- Transaction: Sign and submit transaction to BSC blockchain
- Confirmation: Wait for transaction confirmation
- Response: Return transaction hash and token details
- Rate Limiting: 100 requests per 15 minutes per IP
- Input Validation: Joi schema validation for all inputs
- Error Handling: Secure error messages without sensitive data
- CORS Protection: Configurable CORS for production
- Helmet: Security headers
- Winston Logging: Structured logging with different levels
- Request Logging: All requests logged with duration
- Error Tracking: Comprehensive error logging
- Health Monitoring: Multiple health check endpoints
| Variable | Description | Default |
|---|---|---|
PORT |
Server port | 3001 |
NODE_ENV |
Environment | development |
BSC_RPC_URL |
BSC RPC endpoint | Required |
PRIVATE_KEY |
Wallet private key | Required |
WALLET_ADDRESS |
Wallet address | Required |
FOUR_MEME_API_URL |
Four.Meme API URL | Required |
TOKEN_MANAGER_CONTRACT_ADDRESS |
Contract address | Required |
- Window: 15 minutes
- Max Requests: 100 per IP
- Headers: Rate limit info in response headers
-
Authentication Failed
- Check
PRIVATE_KEYandWALLET_ADDRESS - Verify wallet has sufficient BNB balance
- Check
-
Transaction Failed
- Check gas price and network congestion
- Verify contract address is correct
-
API Rate Limited
- Wait for rate limit window to reset
- Check rate limit headers in response
Check logs in:
logs/error.log- Error logslogs/combined.log- All logs- Console output in development
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY dist ./dist
EXPOSE 3001
CMD ["npm", "start"]npm install -g pm2
pm2 start dist/server.js --name "four-meme-backend"MIT License - see LICENSE file for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
For issues and questions:
- Create an issue in the repository
- Check the troubleshooting section
- Review the logs for error details