Skip to content

kinexbt/four-meme-fork-BE

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Four.Meme Token Launch Backend

A TypeScript backend service for launching meme tokens with PancakeSwap integration, based on the Four.Meme platform.

πŸš€ Features

  • 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

πŸ“‹ Prerequisites

  • Node.js 18+
  • npm or yarn
  • BSC wallet with private key
  • Access to Four.Meme API

πŸ› οΈ Installation

  1. Clone and navigate to backend directory:

    cd backend
  2. Install dependencies:

    npm install
  3. Set up environment variables:

    cp env.example .env

    Edit .env with 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

πŸš€ Running the Server

Development Mode

npm run dev

Production Mode

npm run build
npm start

The server will start on http://localhost:3001 (or your configured PORT).

πŸ“š API Endpoints

Health Checks

  • GET /api/health - Health check
  • GET /api/health/ready - Readiness check
  • GET /api/health/live - Liveness check

Token Management

  • POST /api/token/launch - Launch a new token
  • GET /api/token/status/:txHash - Get transaction status
  • GET /api/token/balance - Get wallet balance
  • POST /api/token/validate - Validate token configuration

πŸ”§ Token Launch Request

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%
}

πŸ”„ How It Works

  1. Authentication: Authenticate with Four.Meme API using wallet signature
  2. Token Info: Get token creation parameters from Four.Meme
  3. Transaction: Sign and submit transaction to BSC blockchain
  4. Confirmation: Wait for transaction confirmation
  5. Response: Return transaction hash and token details

πŸ›‘οΈ Security Features

  • 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

πŸ“Š Monitoring

  • 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

πŸ”§ Configuration

Environment Variables

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

Rate Limiting

  • Window: 15 minutes
  • Max Requests: 100 per IP
  • Headers: Rate limit info in response headers

πŸ› Troubleshooting

Common Issues

  1. Authentication Failed

    • Check PRIVATE_KEY and WALLET_ADDRESS
    • Verify wallet has sufficient BNB balance
  2. Transaction Failed

    • Check gas price and network congestion
    • Verify contract address is correct
  3. API Rate Limited

    • Wait for rate limit window to reset
    • Check rate limit headers in response

Logs

Check logs in:

  • logs/error.log - Error logs
  • logs/combined.log - All logs
  • Console output in development

πŸš€ Deployment

Docker (Recommended)

FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY dist ./dist
EXPOSE 3001
CMD ["npm", "start"]

PM2

npm install -g pm2
pm2 start dist/server.js --name "four-meme-backend"

πŸ“ License

MIT License - see LICENSE file for details.

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

πŸ“ž Support

For issues and questions:

  • Create an issue in the repository
  • Check the troubleshooting section
  • Review the logs for error details

About

The best Memecoin launchpad forked Four.meme - fast and fair token launchpad on BSC (BNB) || Backend & Smart Contract with Solidity - a totally separate version from four.meme smart contract and API

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors