Real-time event streaming for room, contract, and storage updates
Explore the REST API documentation for all Arcade microservices:
WebSocket URL
Connect to the WebSocket server using a valid Privy JWT token in the query string. The token is used to authenticate and identify the player.
const token = 'eyJhbGciOiJS...'; // Privy JWT token
const ws = new WebSocket(`wss://socket.dev.arcade.fyi?token=${token}`);
ws.onopen = () => {
console.log('Connected to Arcade WebSocket');
};
ws.onmessage = (event) => {
const message = JSON.parse(event.data);
console.log('Received:', message.type, message.data);
};
ws.onclose = () => {
console.log('Disconnected');
};
All messages from the server follow this structure:
{
"type": "contract:event" | "room:event" | "storage:event" | "connected" | "pong" | "error",
"data": { ... }
}
Clients can send these message types:
| Type | Description |
|---|---|
ping |
Keep-alive ping, server responds with pong |
subscribe |
Subscribe to a room for targeted events |
unsubscribe |
Unsubscribe from a room |
Contract events are broadcast globally to all connected clients. These events track the lifecycle of smart contract interactions.
Contract record created in database
Blockchain transaction submitted
Transaction confirmed on-chain
Contract rolled back or deleted
Player funded their stake
Player submitted outcome and proof
Player contested mediation decision
Mediator submitted decision
Admin made final decision
Payout completed and distributed
{
"type": "contract:event",
"data": {
"type": "contract.initialized",
"contractId": "550e8400-e29b-41d4-a716-446655440000",
"roomId": "ABC123",
"timestamp": "2024-01-15T10:30:00.000Z",
"payload": {
// Full Contract object
}
}
}
Room events are broadcast to room members only. Players automatically join the room when they're a room participant.
New room created
Player joined the room
Player left the room
Room deleted (last player left)
{
"type": "room:event",
"data": {
"type": "room.joined",
"roomId": "550e8400-e29b-41d4-a716-446655440000",
"roomCode": "ABC123",
"timestamp": "2024-01-15T10:30:00.000Z",
"payload": {
"room": { /* Full Room object */ },
"playerId": "...",
"participantCount": 2
}
}
}
Storage events are broadcast to room members for the contract's associated room.
External URL stored for a contract
Presigned upload URL generated (file not yet uploaded)
Multipart upload completed
Multipart upload aborted
Storage item deleted
{
"type": "storage:event",
"data": {
"type": "storage.presigned_url_created",
"storageId": "550e8400-e29b-41d4-a716-446655440000",
"contractId": "...",
"roomId": "...",
"playerId": "...",
"timestamp": "2024-01-15T10:30:00.000Z",
"payload": {
"storage": { /* Full Storage object */ }
}
}
}
If authentication fails or an error occurs, you'll receive an error message:
{
"type": "error",
"data": {
"message": "Authentication failed",
"code": "AUTH_ERROR"
}
}