Go to file
2025-08-14 16:49:57 +08:00
src spl data fetch fixed 2025-08-14 16:49:57 +08:00
.gitignore init 2025-08-14 01:52:03 +08:00
database-schema.sql final 2025-08-14 10:41:04 +08:00
jest.config.js init 2025-08-14 01:52:03 +08:00
package-lock.json final 2025-08-14 10:41:04 +08:00
package.json final 2025-08-14 10:41:04 +08:00
README.md final 2025-08-14 10:41:04 +08:00
start_server.sh final 2025-08-14 10:41:04 +08:00
tsconfig.json init 2025-08-14 01:52:03 +08:00
VALIDATION_SERVICE.md final 2025-08-14 10:41:04 +08:00

SolPay API

A Node.js TypeScript application for handling Solana transactions.

Setup

1. Install Dependencies

npm install mysql2

2. Environment Variables

Create a .env file in the root directory with the following variables:

# Server Configuration
PORT=3000
NODE_ENV=development
LOG_LEVEL=info

# Database Configuration
DB_HOST=localhost
DB_PORT=3306
DB_USER=root
DB_PASSWORD=your_password_here
DB_NAME=solpay

3. Database Setup

Make sure your MySQL database is running and the solpay database exists with the transactions table.

API Endpoints

Create New Transaction

  • URL: GET /tx/new
  • Method: GET
  • Query Parameters:
    • tx (required): Transaction hash
    • target_address (required): Target wallet address
    • amount (required): Transaction amount
    • token_mint (required): Token mint address
    • token_program (required): Token program address
    • validated_at (required): Validation timestamp
    • sender_address (required): Sender wallet address
    • metadata (optional): Additional metadata

Example Usage

curl "http://localhost:3000/tx/new?tx=abc123&target_address=target123&amount=1.5&token_mint=mint123&token_program=program123&validated_at=2024-01-01T00:00:00Z&sender_address=sender123&metadata=test"

Get All Transactions

  • URL: GET /tx
  • Method: GET

Get Transaction by Hash

  • URL: GET /tx/:txHash
  • Method: GET

Running the Application

# Development
npm run dev

# Build and run
npm run build
npm start

Database Schema

The transactions table should have the following structure:

CREATE TABLE transactions (
  id INT AUTO_INCREMENT PRIMARY KEY,
  tx VARCHAR(255) NOT NULL,
  target_address VARCHAR(255) NOT NULL,
  amount VARCHAR(255) NOT NULL,
  token_mint VARCHAR(255) NOT NULL,
  token_program VARCHAR(255) NOT NULL,
  validated_at VARCHAR(255) NOT NULL,
  sender_address VARCHAR(255) NOT NULL,
  metadata TEXT,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);