| src | ||
| .gitignore | ||
| database-schema.sql | ||
| jest.config.js | ||
| package-lock.json | ||
| package.json | ||
| README.md | ||
| start_server.sh | ||
| tsconfig.json | ||
| VALIDATION_SERVICE.md | ||
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 hashtarget_address(required): Target wallet addressamount(required): Transaction amounttoken_mint(required): Token mint addresstoken_program(required): Token program addressvalidated_at(required): Validation timestampsender_address(required): Sender wallet addressmetadata(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
);