Connection Management
WebSocket connection lifecycle management (authenticate, logout, subscribe)
Connection Basics
HelloTrade uses WebSocket endpoints for real-time data exchange and trading.
Endpoints:
Trading
Production
wss://api.app.hello.trade/ws
Market Data
Production
wss://marketdata.app.hello.trade/ws
Once connected to the trading endpoint, you must authenticate your connection before performing trading operations or subscribing to execution reports.
CLI Example:
wscat -c wss://api.app.hello.trade/ws
# After connection, send authentication (with encoded payload):
{"type":"authenticate","signature":{"sig":"0x...","payload":"0x02..."}}
# Then subscribe to trading:
{"type":"subscribeTrading"}Heartbeat
The server sends periodic ping frames. Clients must respond with pong frames to maintain the connection.
Ping interval
15 seconds
Idle Timeout
30 seconds
Connections are closed after 30 seconds of inactivity (no messages or ping/pong responses).
Reconnection
On disconnect:
Reconnect to WebSocket endpoint
Re-authenticate with fresh nonce
Re-subscribe to trading stream
Reconcile order state from initial snapshot
Always reconcile your local order state with the snapshot received after re-subscribing.
authenticate
Authenticate WebSocket connection with EIP-191 signature.
Request
signature.sig
string
EIP-191 signature (hex-encoded with 0x prefix)
signature.payload
string
Encoded SimpleSignaturePayload (type discriminator 0x02)
Signature Construction:
Create SimpleSignaturePayload struct with
account,nonce, anddeadlineSign the message string:
{account}:{nonce}(note: deadline not in message, only in struct)Encode the struct with type discriminator byte
0x02
See Signatures - EIP-191 Operations for complete details.
Success Response
Common Errors
4001
Signature verification failed
4002
Invalid nonce (expired, replay, or out of window)
4029
Rate limit exceeded
5000
Connection limit exceeded (>8 connections)
5003
Failed to create or retrieve account
logout
Clear authentication state and unsubscribe from trading stream.
Authentication Required: Yes
Request
No parameters required.
Success Response
Connection returns to unauthenticated state. To trade again, send new authenticate message.
subscribeTrading
Subscribe to execution reports stream.
Authentication Required: Yes
After successful subscription, the gateway automatically:
Sends initial order snapshot (all resting orders for the account)
Streams real-time execution reports for order updates, trades, and account events
Request
No parameters required. Uses authenticated wallet from authenticate message.
Success Response
Execution Report Flow
After subscription:
Order snapshot - All resting orders sent as execution reports with
messageType: "OrderStatus"Real-time updates - Ongoing execution reports for:
Order status changes (filled, cancelled, etc.)
Trade executions
Account events (deposits, withdrawals, leverage updates, liquidations)
See Execution Reports for message formats.
Common Errors
4003
Not authenticated (send authenticate first)
4029
Rate limit exceeded
4033
Already subscribed to trading stream
5000
Internal error
5001+
Exchange error (5001 + exchange error code)
Last updated