Getting Started
Quick guide to get up and running with the Rugplay Logger.
Table of contents
- Installation
- Quick Start
- Configuration
- First Steps
- Common Use Cases
- Troubleshooting
- Next Steps
- Getting Help
Installation
Prerequisites
- Node.js 18.0 or higher
- npm or bun package manager
- TypeScript (included as dev dependency)
Clone and Install
# Clone the repository
git clone https://github.com/your-username/rugplay-logger.git
cd rugplay-logger
# Install dependencies
npm install
# Or using bun
bun install
Build the Project
# Build TypeScript to JavaScript
npm run build
# Or using bun
bun run build
Quick Start
1. Basic Setup
The simplest way to start logging Rugplay events:
import { RugplayClient } from './src/client/RugplayClient';
import { webSocketConfig } from './src/configuration/websocket';
const client = new RugplayClient({
config: webSocketConfig,
autoConnect: true,
debug: true
});
// Log all trade events
client.on('trade', (data) => {
console.log(`Trade: ${data.username} ${data.tradeType} ${data.coinSymbol}`);
});
console.log('π Rugplay Logger started!');
2. Running the Application
# Using npm
npm start
# Using bun for faster startup
npm run bun-start
# Development mode with auto-reload
npm run dev
3. Verify Connection
You should see output similar to:
π Starting Rugplay Logger...
β
Connected to Rugplay WebSocket
π¨ Trade: trader123 buy MOON
π¨ Trade: cryptowhale sell ROCKET
Configuration
Environment Setup
Create a .env file in the project root:
# WebSocket Configuration
WEBSOCKET_URL=wss://ws.rugplay.com/
RECONNECT_ATTEMPTS=5
RECONNECT_DELAY=1000
# Export Configuration
FILE_EXPORT_ENABLED=true
EXPORT_PATH=./exports/rugplay-data.json
EXPORT_FORMAT=json
# Discord Integration (optional)
DISCORD_ENABLED=false
DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/YOUR_WEBHOOK_URL
DISCORD_FORMAT=embed
# Logging
DEBUG_MODE=true
Update Configuration Files
Edit the configuration files to match your needs:
WebSocket Configuration (src/configuration/websocket.ts):
const webSocketConfig: WebSocketConfig = {
url: process.env.WEBSOCKET_URL || 'wss://ws.rugplay.com/',
reconnectAttempts: parseInt(process.env.RECONNECT_ATTEMPTS || '5'),
reconnectDelay: parseInt(process.env.RECONNECT_DELAY || '1000')
};
Export Configuration (src/configuration/export.ts):
const exportConfig: ExportConfig = {
file: {
enabled: process.env.FILE_EXPORT_ENABLED === 'true',
outputPath: process.env.EXPORT_PATH || './exports/data.json',
format: (process.env.EXPORT_FORMAT as any) || 'json'
},
discord: {
enabled: process.env.DISCORD_ENABLED === 'true',
webhookUrl: process.env.DISCORD_WEBHOOK_URL || '',
messageFormat: (process.env.DISCORD_FORMAT as any) || 'embed'
}
};
First Steps
1. Monitor Specific Tokens
const watchedTokens = ['MOON', 'ROCKET', 'SAFE'];
client.on('trade', (data) => {
if (watchedTokens.includes(data.coinSymbol)) {
console.log(`π― Watched token trade: ${data.coinSymbol} - $${data.totalValue}`);
}
});
client.on('price', (data) => {
if (watchedTokens.includes(data.symbol)) {
console.log(`π² ${data.symbol} price: $${data.price} (${data.priceChange24h}%)`);
}
});
2. Set Up Alerts
// Large trade alerts
client.on('trade', (data) => {
if (data.totalValue > 1000) {
console.log(`π¨ Large trade: ${data.username} - $${data.totalValue.toLocaleString()}`);
}
});
// Price spike alerts
let lastPrices = new Map();
client.on('price', (data) => {
const lastPrice = lastPrices.get(data.symbol);
if (lastPrice) {
const change = ((data.price - lastPrice) / lastPrice) * 100;
if (change > 20) {
console.log(`π Price spike: ${data.symbol} up ${change.toFixed(2)}%`);
}
}
lastPrices.set(data.symbol, data.price);
});
3. Enable Data Export
import { exportConfig } from './src/configuration/export';
const client = new RugplayClient({
config: webSocketConfig,
exportConfig: exportConfig, // Enable automatic data export
autoConnect: true
});
This will automatically save all events to files in the format you configured.
Common Use Cases
Trading Bot Integration
class TradingSignalGenerator {
constructor(private client: RugplayClient) {
this.setupSignals();
}
private setupSignals(): void {
// Volume spike detection
this.client.on('trade', (data) => {
if (data.totalValue > 5000) {
this.generateSignal('VOLUME_SPIKE', data);
}
});
// Price movement tracking
this.client.on('price', (data) => {
if (Math.abs(data.priceChange24h) > 15) {
this.generateSignal('PRICE_MOVEMENT', data);
}
});
}
private generateSignal(type: string, data: any): void {
console.log(`π€ Trading Signal: ${type}`, data);
// Integrate with your trading bot here
}
}
const signalGenerator = new TradingSignalGenerator(client);
Research and Analytics
class DataCollector {
private trades: any[] = [];
private prices: any[] = [];
constructor(private client: RugplayClient) {
this.setupCollection();
}
private setupCollection(): void {
this.client.on('trade', (data) => {
this.trades.push({
timestamp: new Date(),
symbol: data.coinSymbol,
type: data.tradeType,
amount: data.amount,
price: data.price,
value: data.totalValue
});
});
// Export data every hour for analysis
setInterval(() => {
this.exportData();
}, 60 * 60 * 1000);
}
private exportData(): void {
console.log(`π Collected ${this.trades.length} trades and ${this.prices.length} price updates`);
// Export to your preferred analytics platform
}
}
const collector = new DataCollector(client);
Troubleshooting
Connection Issues
If youβre having trouble connecting:
- Check the WebSocket URL: Ensure
wss://ws.rugplay.com/is accessible - Firewall/Proxy: Make sure WebSocket connections arenβt blocked
- Network: Try from a different network if issues persist
client.on('error', (error) => {
console.error('Connection error:', error);
});
client.on('disconnect', () => {
console.log('Disconnected - will attempt reconnection');
});
Performance Issues
For high-frequency trading data:
- Enable buffering in EventLogger
- Filter events to reduce processing load
- Use efficient data structures for tracking
// Filter only high-value trades
client.on('trade', (data) => {
if (data.totalValue > 100) { // Only process trades > $100
// Your processing logic
}
});
Memory Usage
For long-running processes:
// Implement data cleanup
setInterval(() => {
// Clear old data to prevent memory leaks
if (this.trades.length > 10000) {
this.trades = this.trades.slice(-5000); // Keep only recent 5000
}
}, 30 * 60 * 1000); // Every 30 minutes
Next Steps
- Read the API Reference for detailed documentation
- Explore Configuration Options for advanced setup
- Check out Examples for real-world use cases
- Learn about Event Types to understand available data
Getting Help
- Issues: Report bugs or request features on GitHub Issues
- Discussions: Join discussions on GitHub Discussions
- Discord: Join our community Discord server for real-time help