Wire Protocol
MessagePack encoding conventions, data types, and serialization rules for Titan's API.
This page covers how data is encoded on the wire — the serialization format, encoding conventions, and shared types used across all Titan API messages.
Both Titan Direct and Titan Gateway use MessagePack binary encoding. JSON is not supported.
Data format
The basic data format for serialization of all messages is MessagePack.
Objects/structs are encoded as maps — this allows additional fields to be added without breaking compatibility with previous versions.
Field names are
camelCaseunless otherwise specified.Integers are encoded using the smallest MessagePack int type that fits the value.
Use
BigIntforu64values (amounts, timestamps) — values above 2^53 lose precision as float64, which the server rejects.
Optional data
If a value is optional, its type is Option<T> in Rust and T? or T | null in TypeScript.
Optional fields in objects may be omitted entirely from the serialized map. Otherwise, a missing optional value should be encoded as nil (0xc0) — decoded as None in Rust and null in TypeScript.
Simple enumerations
Simple enumerations (those without associated data) are encoded as strings matching the variant name exactly:
enum SwapMode {
ExactIn,
ExactOut,
}
// Encoded as: "ExactIn" or "ExactOut"enum SwapMode {
ExactIn = "ExactIn",
ExactOut = "ExactOut",
}Complex enumerations
Complex enumerations (those with associated data) are encoded as single-value maps, mapping the variant name to the associated data.
Single associated item → the value is that data.
Multiple associated items → the value is an array.
This pattern applies to both client requests (RequestData) and server messages (ServerMessage). To determine the message type, check which key is present in the top-level map.
Binary data
Binary data is encoded using MessagePack bin formats.
TypeScript has no way to specify byte array size — refer to the Rust types for size constraints.
Common types
Pubkey
Solana public keys are 32-byte binary data. Encoded using MessagePack bin 8 format — all pubkeys start with c4 20 followed by 32 bytes of key data.
Example — the WSOL public key So11111111111111111111111111111111111111112:
AccountMeta
Compact account descriptor used in instructions. Uses single-letter field names to minimize message size.
Instruction
A single on-chain instruction. Also uses single-letter field names for compactness.
Message envelope types
ClientRequest
Every client request wraps an RPC method call with a monotonically increasing id.
ServerMessage
The server sends one of four message types:
Compression
Compression wraps the MessagePack payload. The order of operations:
Sending: serialize to MessagePack → compress → send as binary WebSocket frame
Receiving: receive binary frame → decompress → deserialize from MessagePack
The compression scheme is negotiated once at connection time. See Connection & Negotiation for protocol strings and setup.
Gateway differences
Titan Gateway uses the same MessagePack encoding but over HTTP REST:
Requests — query parameters (pubkeys as Base58 strings, not binary)
Responses — MessagePack body with
Content-Type: application/vnd.msgpackPubkeys in responses are still binary
Uint8Arrayin the MessagePack body
Related pages
Connection & Negotiation — WebSocket setup, authentication, and compression negotiation
GetInfo — server settings and protocol version
NewSwapQuoteStream — streaming swap quotes
Last updated

