7.4 KiB
7.4 KiB
Trade System Setup Guide
Quick Start (Development Mode - No Steam Bots Required)
For testing the trade system without real Steam bots:
1. Enable Bypass Mode
Add to your .env file:
NODE_ENV=development
BYPASS_BOT_REQUIREMENT=true
2. Restart Backend
npm run dev
3. Test the Flow
- Go to
/sellpage - Select items to sell
- Click "Sell Selected Items"
- You'll get a mock trade with verification code
- To complete the trade and credit balance:
Or use the frontend to call:
# Get the trade ID from the response, then: curl -X POST http://localhost:3000/api/inventory/trade/TRADE_ID/complete \ -H "Cookie: accessToken=YOUR_TOKEN"POST /api/inventory/trade/:tradeId/complete
4. Check Balance
Your balance should be credited automatically!
Production Setup (With Real Steam Bots)
Prerequisites
You need:
- ✅ Steam account(s) for bots
- ✅ Steam Mobile Authenticator enabled on each bot account
- ✅
shared_secretandidentity_secretfor each bot - ✅ Steam API Key (get one here)
- ⚠️ Optional: SOCKS5/HTTP proxies (recommended for multiple bots)
Step 1: Extract Bot Secrets
Using SDA (Steam Desktop Authenticator):
- Install SDA on your computer
- Add your bot account to SDA
- Navigate to SDA's data folder:
- Windows:
%APPDATA%\SteamDesktopAuthenticator - Linux:
~/.config/SteamDesktopAuthenticator
- Windows:
- Open
maFiles/<steamid>.maFile - Copy
shared_secretandidentity_secret
Using steam-totp:
// If you have your Steam Guard secret:
import SteamTotp from 'steam-totp';
const code = SteamTotp.generateAuthCode('YOUR_SHARED_SECRET');
Step 2: Create Bot Configuration
Create config/steam-bots.json:
[
{
"username": "turbotrades_bot1",
"password": "your_steam_password",
"sharedSecret": "abcd1234efgh5678ijkl==",
"identitySecret": "wxyz9876vuts5432pqrs==",
"steamApiKey": "YOUR_STEAM_API_KEY",
"pollInterval": 30000,
"tradeTimeout": 600000,
"proxy": {
"type": "socks5",
"host": "proxy.example.com",
"port": 1080,
"username": "proxy_user",
"password": "proxy_password"
}
}
]
Notes:
proxyis optional but recommended for multiple botspollInterval: How often to check for trade updates (ms)tradeTimeout: How long before trade auto-cancels (ms)
Step 3: Enable Auto-Start
Add to .env:
STEAM_BOT_AUTO_START=true
Step 4: Start Backend
npm run dev
You should see:
🤖 Auto-starting Steam bots...
✅ Bot turbotrades_bot1 ready
✅ 1/1 bots initialized successfully
Step 5: Test Trade Flow
- Set your trade URL in profile (
/profile) - Go to sell page (
/sell) - Select items
- Create trade offer
- Check Steam for trade offer
- Verify code matches
- Accept trade in Steam
- Balance credited automatically!
Manual Bot Initialization (Alternative)
If you don't want auto-start, you can initialize bots via API:
// In your code or via admin endpoint
import { getSteamBotManager } from './services/steamBot.js';
const botManager = getSteamBotManager();
const botsConfig = [
{
username: "bot1",
password: "pass",
sharedSecret: "secret",
identitySecret: "secret"
}
];
await botManager.initialize(botsConfig);
Environment Variables Reference
# Development Mode (bypass bots)
NODE_ENV=development
BYPASS_BOT_REQUIREMENT=true
# Production Mode (real bots)
NODE_ENV=production
STEAM_BOT_AUTO_START=true
STEAM_APIS_KEY=your_steam_api_key
# Optional
ENABLE_PRICE_UPDATES=true
Verification Codes
- Format: 6 alphanumeric characters (e.g.,
A3X9K2) - Purpose: Prevent phishing attacks
- How it works:
- Code shown on website
- Code included in Steam trade message
- User must verify codes match before accepting
WebSocket Events (Real-time Updates)
Your frontend will receive these events:
trade_creating- Trade is being createdtrade_sent- Trade sent to Steamtrade_confirmed- Trade confirmed with 2FAtrade_created- Trade ready (includes verification code)trade_accepted- User accepted on Steamtrade_completed- Balance creditedbalance_update- Balance changedtrade_declined- User declinedtrade_expired- Trade expiredtrade_canceled- Trade canceled
Monitoring
Check Bot Health
# Via admin endpoint (requires admin role)
curl http://localhost:3000/api/admin/bots/health
Check Bot Stats
import { getSteamBotManager } from './services/steamBot.js';
const botManager = getSteamBotManager();
const stats = botManager.getStats();
console.log(stats);
// {
// totalBots: 2,
// healthyBots: 2,
// totalTrades: 15,
// totalActiveTrades: 3,
// totalErrors: 0
// }
View Trade History
curl http://localhost:3000/api/inventory/trades \
-H "Cookie: accessToken=YOUR_TOKEN"
Troubleshooting
"Trade system unavailable"
Cause: Bots not initialized
Solution:
- Development: Set
BYPASS_BOT_REQUIREMENT=true - Production: Check bot config and set
STEAM_BOT_AUTO_START=true
"Bot login failed"
Causes:
- Wrong username/password
- Wrong shared_secret
- Steam Guard not enabled
- Account locked/banned
Solution:
- Verify credentials
- Test login manually via Steam client
- Check bot account is not limited (spent $5+ on Steam)
"Confirmation failed"
Cause: Wrong identity_secret
Solution:
- Double-check identity_secret from SDA maFile
- Ensure mobile auth is enabled
Trade created but not appearing in Steam
Causes:
- User's trade URL is incorrect
- User's inventory is private
- Items became untradable
Solution:
- Verify trade URL format
- Make inventory public
- Check item trade restrictions
Balance not credited after accepting trade
Causes:
- Backend event listener not working
- Database error
- WebSocket disconnected
Solution:
- Check backend logs for
tradeAcceptedevent - Check Trade status in database
- Manually complete via:
POST /api/inventory/trade/:tradeId/complete(dev only)
Security Best Practices
- ✅ Never expose bot credentials - Store in secure config, not in code
- ✅ Use proxies - Distribute bot IPs to avoid rate limits
- ✅ Monitor bot health - Set up alerts for bot failures
- ✅ Verification codes - Always show and require verification
- ✅ Rate limiting - Limit trades per user per hour
- ✅ Escrow handling - Warn users about 7-day trade holds
- ✅ Audit logs - Log all trade events for debugging
API Endpoints Summary
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/inventory/sell |
Create trade offer |
| GET | /api/inventory/trades |
Get trade history |
| GET | /api/inventory/trade/:id |
Get trade details |
| POST | /api/inventory/trade/:id/cancel |
Cancel pending trade |
| POST | /api/inventory/trade/:id/complete |
Complete trade (dev only) |
Need Help?
- 📖 Read
TRADE_WORKFLOW.mdfor detailed flow documentation - 🤖 Read
STEAM_BOT_SETUP.mdfor bot setup details - 🔧 Check logs in backend console
- 💬 Check WebSocket messages in browser dev tools