Skip to content

Muzided/sol-ico-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Solana ICO Backend

A Node.js backend application for managing Solana wallet registrations and token purchases.

Features

  • User registration with Solana wallet address
  • JWT-based authentication
  • Token purchase tracking
  • Purchase history management

Prerequisites

  • Node.js (v14 or higher)
  • MongoDB
  • npm or yarn

Setup

  1. Clone the repository
  2. Install dependencies:
    npm install
  3. Create a .env file in the root directory with the following variables:
    PORT=3000
    MONGODB_URI=mongodb://localhost:27017/sol-ico
    JWT_SECRET=your_jwt_secret_key_here
    JWT_EXPIRES_IN=7d
    
  4. Start the server:
    npm run dev

API Endpoints

Authentication

  • POST /api/auth/register

    • Register a new user with Solana wallet address
    • Body: { "walletAddress": "your_solana_wallet_address" }
  • POST /api/auth/login

    • Login with Solana wallet address
    • Body: { "walletAddress": "your_solana_wallet_address" }

Purchases

  • POST /api/purchases

    • Create a new purchase record
    • Headers: Authorization: Bearer <token>
    • Body:
      {
        "tokenPurchased": 100,
        "presaleActivePhase": 1,
        "usdtSent": 1000,
        "transactionHash": "transaction_hash_here"
      }
  • GET /api/purchases/my-purchases

    • Get current user's purchase history
    • Headers: Authorization: Bearer <token>
  • GET /api/purchases/all

    • Get all purchases (admin only)
    • Headers: Authorization: Bearer <token>

Security

  • JWT-based authentication
  • Protected routes
  • Input validation
  • Error handling

Error Handling

The API returns appropriate HTTP status codes and error messages in case of failures:

  • 400: Bad Request
  • 401: Unauthorized
  • 404: Not Found
  • 500: Internal Server Error

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published