Create, trade, and manage tokens on the Γ¦ternity blockchain with advanced features and multi-level affiliation system.
- Project Overview
- Related Components
- Project Architecture
- System Requirements
- Quick Start with Docker
- Manual Installation
- Environment Configuration
- Available Scripts
- Docker Services
- Token Categories Configuration
- Development
- Contributing Guide
- Production Deployment
- Contributing
- License
This API serves as a caching and synchronization layer for the Bonding Curve Community platform on the Aeternity blockchain. It provides real-time token data, pricing information, and transaction history while maintaining collection-specific validation rules.
- bctsl/bctsl-sdk - SDK for interacting with the bonding curve contracts
- bctsl/bctsl-contracts - Smart contracts for the bonding curve token sale platform
- bctsl/bcl - Frontend application for the Bonding Curve Community platform
- π Multi-Collection Support: Handle multiple token collections with unique naming conventions and validation rules
- β‘ Real-time Pricing: Synchronize and cache token pricing from the bonding curve contracts
- π Transaction Tracking: Monitor and validate buy/sell transactions
- π Data Rankings: Provide token rankings globally and per collection
- π WebSocket Events: Broadcast real-time updates for token prices, creation, and transactions
- π§Ή Data Reorganization: Automatically handle and remove invalid transactions
- π MDW Integration: Seamless integration with Aeternity Middleware (MDW)
src/
βββ ae/ # Aeternity blockchain integration
βββ ae-pricing/ # Pricing calculation and synchronization
βββ configs/ # Application configuration
βββ tokens/ # Token management and WebSocket events
βββ transactions/ # Transaction processing and validation
βββ utils/ # Utility functions and helpers
-
π« Token Management (
src/tokens/)- Token data caching and retrieval
- WebSocket gateway for real-time updates
- Collection-specific validation rules
- Token ranking calculations
- Price history tracking
-
π± Transaction Processing (
src/transactions/)- Transaction monitoring and validation
- Buy/Sell operation tracking
- Invalid transaction handling
- Transaction history management
-
β Aeternity Integration (
src/ae/)- MDW client implementation
- Blockchain event monitoring
- Contract interaction
- Network synchronization
-
π° Pricing Engine (
src/ae-pricing/)- Price synchronization
-
π¦ Initialization
- Load collection configurations
- Establish MDW connection
- Initialize WebSocket server
- Start price synchronization
-
π« Token Operations
- Validate token names against collection rules
- Calculate and cache token prices
- Track token ownership
- Update token rankings
- Broadcast token events
-
πΈ Transaction Handling
- Monitor blockchain for new transactions
- Validate transaction legitimacy
- Update token prices and ownership
- Broadcast transaction events
- Handle transaction reorganization
-
π Data Synchronization
- Periodic price updates
- Transaction history synchronization
- Data cleanup and validation
- Cache management
-
π« Token Endpoints
- Token validation
- Price history retrieval
- Token rankings (global/collection)
-
π± Transaction Endpoints
- Transaction history
- Transaction validation status
-
π WebSocket Events
- Token price updates
- New token creation
- Transaction notifications
- Collection updates
-
π Collection Management
- Collection configuration
- Validation rules
- Naming conventions
- Character code restrictions
The API implements a multi-layer caching strategy:
-
π‘ In-Memory Cache
- Active token prices
- Recent transactions
- Validation rules
-
β‘ Redis Cache
- Token rankings
- Price history
- Collection statistics
-
π½ PostgreSQL Database
- Historical data
- Transaction records
- Token metadata
- Collection configurations
- π¦ Node.js >= 18
- ποΈ PostgreSQL >= 16
- π Redis (latest)
- π³ Docker and Docker Compose (for containerized setup)
The easiest way to run the application is using Docker Compose:
# Clone the repository
git clone https://github.com/bctsl/bctsl-api.git
cd bctsl-api
# Setup environment variables
cp .env.example .env
# Start all services
docker compose up --buildThe application will be available at http://localhost:3000.
If you prefer to run the services locally:
# Install dependencies
npm install
# Setup environment variables
cp .env.example .env
# Start the development server
npm run start:devConfigure the following environment variables in your .env file:
# Database Configuration
DB_TYPE=postgres
DB_HOST=127.0.0.1 # Use 'postgres' if running with Docker
DB_PORT=5432
DB_USER=postgres
DB_PASSWORD=postgres # Change in production
DB_DATABASE=bcl_api
DB_SYNC=true # Set to false in production
# Redis Configuration
REDIS_HOST=localhost # Use 'redis' if running with Docker
REDIS_PORT=6379
# Network Configuration
AE_NETWORK_ID=ae_mainnet # or ae_uat for testnet
# Application Configuration
APP_PORT=3000# Development
npm run start # Start the application
npm run start:dev # Start with hot-reload
npm run start:prod # Start in production modeThe project includes three main services:
-
API Service (
api):- NestJS application
- Runs on port 3000
- Auto-reloads in development
-
PostgreSQL (
postgres):- Version 16
- Persists data in a Docker volume
- Accessible on port 5432
-
Redis (
redis):- Latest Alpine version
- Persists data in a Docker volume
- Accessible on port 6379
Define the collections you want the API to support in src/configs/contracts.ts:
export const BCL_FACTORY: Record<INetworkTypes, ICommunityFactorySchema> = {
[NETWORK_ID_MAINNET]: {
address: 'ct_..',
collections: {
// Example configuration:
// 'CATEGORY-ak_..': {
// name: 'CATEGORY',
// allowed_name_length: '20',
// description: 'Tokenize a unique name with up to 20 characters',
// },
},
},
[NETWORK_ID_TESTNET]: {
address: 'ct_..',
collections: {}
}
};For detailed information about our development standards, testing practices, and contribution guidelines, please see our Contributing Guide.
# Start all services
docker compose up
# Start services in background
docker compose up -d
# Stop all services
docker compose down
# View logs
docker compose logs -f
# Rebuild services
docker compose up --buildThe database automatically syncs schema changes in development (DB_SYNC=true). For production, you should manage database migrations manually.
For production deployment:
- Set appropriate environment variables
- Disable
DB_SYNC - Use proper secrets management
- Configure proper network settings
- Enable SSL/TLS
We welcome contributions! Please see our Contributing Guide for details on:
- Development standards
- Code style and linting
- Testing requirements
- Commit message conventions
- Pull request process
This project is licensed under the ISC License - see the LICENSE file for details.
Copyright (c) 2025, BCTSL