Trading Key Authentication (Ed25519)
Every trading request is authenticated by an Ed25519 signature computed locally in your process. The flow is:- You generate an Ed25519 keypair and register the public key with Molecule.
- For each request, the SDK computes a canonical string from the HTTP method, path, sorted query parameters, timestamp, and SHA-256 body hash.
- The SDK signs that string with your private key and attaches three headers to the outgoing request.
Signing headers
The SDK attaches all three headers automatically whenever you construct a client with
key_id and private_key. You do not need to compute or attach them yourself.
Initialize the client with a trading key
Pass yourkey_id and private_key directly to the Molecule constructor. The base_url is required — set it via the MOLECULE_BASE_URL environment variable or pass it explicitly.
Accepted private key formats
The SDK’sload_private_key function accepts the following representations of a 32-byte Ed25519 seed:
The canonical format is base64 of the 32-byte seed, matching what the key-generation snippet in Key Management produces. Use that format for all stored credentials.
JWT Token Authentication (Management Routes)
Account management routes — such as configuring organizations, managing users, and accessing dashboard-level resources — require a JWT issued by the Molecule platform. Pass the token to thetoken= parameter of the constructor. The SDK sends it as an Authorization: Bearer <token> header.
Do not pass both
private_key and token to the same client instance. When both are present, the SDK prioritises Ed25519 signing and ignores the token. Use separate client instances for trading and management operations.Error reference
The table below maps error codes to their Python exception class and the remediation action.Next steps
Key Management
Generate an Ed25519 keypair, export the seed in the canonical base64 format, and load it securely in your process.
Request Signing
Understand the canonical string construction, replay protection, and WebSocket signing in detail.
