Getting Started
Quick start guide for LX - installation, setup, and your first trade
Getting Started with LX
Specification: LP-9000 DEX Core | LP-9002 DEX API | Discussions
Implementation:
github.com/luxfi/dex
Get up and running with LX in minutes.
Prerequisites
- Go 1.21+ (for building from source)
- Git
- Docker (optional, for containerized deployment)
Installation
From Source
# Clone the repository
git clone https://github.com/luxfi/dex.git
cd dex
# Build the project
make build
# Verify installation
./bin/luxd --versionFrom Release
# Download latest release
curl -L https://github.com/luxfi/dex/releases/latest/download/lx-dex-$(uname -s | tr '[:upper:]' '[:lower:]')-$(uname -m) -o lx-dex
# Make executable
chmod +x lx-dex
# Run
./lx-dexWith Docker
# Pull the image
docker pull luxfi/dex:latest
# Run the container
docker run -p 8080:8080 -p 8081:8081 -p 50051:50051 luxfi/dex:latestStart the Node
Single Node (Development)
# Start with default configuration
./bin/luxd
# Or with custom config
./bin/luxd --config config.yamlMulti-Node Cluster
# Start a 3-node cluster
make run-clusterDocker Compose
# Start all services
docker-compose up -d
# View logs
docker-compose logs -fVerify Installation
Check Node Health
curl http://localhost:8080/healthExpected response:
{"status": "healthy", "version": "1.0.0"}Test JSON-RPC
curl -X POST http://localhost:8080/rpc \
-H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0", "method": "lx_ping", "params": {}, "id": 1}'Expected response:
{"jsonrpc": "2.0", "result": {"pong": true}, "id": 1}Your First Trade
Using curl
# Place a buy order
curl -X POST http://localhost:8080/rpc \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "lx_placeOrder",
"params": {
"symbol": "BTC-USD",
"type": 0,
"side": 0,
"price": 50000,
"size": 1.0,
"userID": "trader1"
},
"id": 1
}'Using TypeScript SDK
import { DEX } from '@luxfi/trading'
const dex = await DEX({ rpcUrl: 'http://localhost:8080/rpc' })
// Place a buy order
const order = await dex.limitBuy('BTC-USD', '1.0', '50000')
console.log('Order ID:', order.orderId)Using Python SDK
from lux_dex import Client
client = Client(
json_rpc_url='http://localhost:8080/rpc'
)
# Place a buy order
order = client.place_order(
symbol='BTC-USD',
order_type='limit',
side='buy',
price=50000,
size=1.0
)
print(f'Order ID: {order.order_id}')Using Go SDK
package main
import (
"context"
"fmt"
"github.com/luxfi/dex/sdk/go/lxdex"
)
func main() {
client := lxdex.NewClient(
lxdex.WithJSONRPC("http://localhost:8080/rpc"),
)
order, _ := client.PlaceOrder(context.Background(), &lxdex.Order{
Symbol: "BTC-USD",
Type: lxdex.OrderTypeLimit,
Side: lxdex.Buy,
Price: 50000,
Size: 1.0,
})
fmt.Printf("Order ID: %s\n", order.OrderID)
}View Order Book
Using curl
curl -X POST http://localhost:8080/rpc \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "lx_getOrderBook",
"params": {"depth": 10},
"id": 1
}'Using WebSocket
const ws = new WebSocket('ws://localhost:8081');
ws.onopen = () => {
ws.send(JSON.stringify({
type: 'subscribe',
channel: 'orderbook',
symbol: 'BTC-USD',
depth: 10
}));
};
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
console.log('Order book:', data);
};Configuration
Environment Variables
| Variable | Description | Default |
|---|---|---|
LX_RPC_PORT | JSON-RPC port | 8080 |
LX_WS_PORT | WebSocket port | 8081 |
LX_GRPC_PORT | gRPC port | 50051 |
LX_P2P_PORT | P2P networking port | 5000 |
LX_LOG_LEVEL | Log level (debug, info, warn, error) | info |
LX_DATA_DIR | Data directory | ./data |
Configuration File
# config.yaml
server:
rpc_port: 8080
ws_port: 8081
grpc_port: 50051
consensus:
validators: 3
block_time: 1ms
storage:
path: ./data
engine: badger
logging:
level: info
format: jsonDefault Ports
| Service | Port | Protocol |
|---|---|---|
| JSON-RPC | 8080 | HTTP |
| WebSocket | 8081 | WS |
| gRPC | 50051 | HTTP/2 |
| P2P | 5000 | TCP |
| Metrics | 9090 | HTTP |
Next Steps
- API Reference - Complete API documentation
- Architecture - System design overview
- SDK Guide - Client library integration
- Development - Build and contribute
Troubleshooting
Port Already in Use
# Find process using port
lsof -i :8080
# Kill process
kill -9 <PID>Connection Refused
Check if the node is running:
ps aux | grep luxdCheck firewall rules:
# macOS
sudo pfctl -s rules
# Linux
sudo iptables -LPermission Denied
# Fix binary permissions
chmod +x ./bin/luxd
# Fix data directory permissions
chmod 755 ./dataSupport
- Documentation: https://dex.lux.network
- GitHub Issues: https://github.com/luxfi/dex/issues
- Discord: https://discord.gg/luxfi
- Email: [email protected]