PolyesterClient
new PolyesterClient(config: PolyesterClientConfig)| Option | Type | Default | Description |
|---|---|---|---|
environment | PolyesterEnvironment | required | Endpoints + chain config. See Environments. |
auth | JwtAuthProvider | ApiKeyEd25519AuthProvider | none | Credentials for authenticated services and private realtime channels. |
interceptors | Interceptor[] | [] | ConnectRPC interceptors applied to every request. |
wireFormat | "binary" | "json" | "binary" | Connect wire format. Use json for human-readable debugging. |
realtime | PolyesterRealtimeAuthConfig | derived from auth | Override getAuthHeaders / hasAuth for WebSocket auth. |
catalogSnapshot | CatalogSnapshot | none | Initial reference-data snapshot (e.g. from SSR). |
catalogCell | CatalogSnapshotCell | none | External (optionally reactive) snapshot storage. |
catalog | ClientCatalog | none | Fully managed catalog instance. Mutually exclusive with the two above. |
Properties: one lazy getter per service (auth, accounts, apiKeys, subaccounts, candles, chainAnalytics, marketData, marketOverview, orderbook, heatmap, lifecycle, trades, orders, triggers, balances, transfers, internalTransfers, tradingWithdraws, deposit, addressBook, guardSigner, socialVerification, whiteboard, zipper, mfa),
plus realtime (the shared RealtimeClient) and catalog (the ClientCatalog).
Auth providers
interface JwtAuthProvider {
kind: "jwt";
getToken: () => string | null | Promise<string | null>;
}
interface ApiKeyEd25519AuthProvider {
kind: "api-key-ed25519";
getKeyId: () => string | null | Promise<string | null>;
getSecretKey: () => Uint8Array | null | Promise<Uint8Array | null>; // 32-byte secret
}PolyesterBrowserClient
new PolyesterBrowserClient(config: PolyesterBrowserClientConfig)Extends the base config (minus auth, which it manages) with:
| Option | Type | Default | Description |
|---|---|---|---|
accountSigner | AccountSigner | () => AccountSigner | null | Promise<…> | none | The signer used for login; factories resolve lazily. |
tokenStorage | AuthTokenStorage | in-memory | Where the JWT lives. createCookieAuthTokenStorage() persists across reloads/SSR. |
Additional members: auth is narrowed to AccountSignerAuthService (login/logout/sessions/events — see the Account services reference), and setAccountSigner(signer | null) swaps the signer at runtime.
Token storage implementations:
createMemoryAuthTokenStorage(initialToken?)
createCookieAuthTokenStorage({ cookieName?, path?, secure?, sameSite? })PolyesterServerClient
new PolyesterServerClient(config: PolyesterServerClientConfig)Extends the base config with:
| Option | Type | Default | Description |
|---|---|---|---|
session | ServerSessionSnapshot | empty | Display-only session data parsed from cookies. |
useDisplaySessionActiveAccountAsDefault | boolean | false | Treat the display session's active account as the default subaccount scope. |
Members: session, hasAuthProvider, hasBearerToken, hasUsableBearerToken, hasDisplaySession, and verifySession(): Promise<Me | null>.
Factories
createPolyesterServerClientFromRequest({ environment, request, ...baseOptions })
createPolyesterServerClientFromCookies({ environment, cookies, ...baseOptions })Both parse the session cookies, attach a JWT provider when a valid bearer token is present, and
return a configured PolyesterServerClient. Related helpers: parseSessionCookie(cookies, environment), getBearerTokenFromCookies(cookies, environment), and the exported cookie-name
constants POLYESTER_AUTH_TOKEN_COOKIE_NAME / POLYESTER_SESSION_COOKIE_NAME.
Request options
Every service method takes an options object as its last parameter:
interface PolyesterRequestOptions {
signal?: AbortSignal; // cancel the request
}
interface PolyesterMutationOptions extends PolyesterRequestOptions {
stepUpToken?: string | null; // MFA fresh step-up proof (sent as X-Auth-Step-Up)
}Reads take PolyesterRequestOptions; mutations take PolyesterMutationOptions.
Environments
POLYESTER_TESTNET_ENVIRONMENT: PolyesterEnvironment
createPolyesterEnvironment(params: CreatePolyesterEnvironmentParams): PolyesterEnvironmentSee Environments for the full parameter reference and validation rules.
Package entry points
| Entry point | Runtime exports |
|---|---|
@polyester/sdk | PolyesterClient, PolyesterBrowserClient, PolyesterServerClient, server-client factories, environments, token storage, the full error tree, EVM/time utilities, and all service input/output types |
@polyester/sdk/account-signer | createPolyesterAccountSigner |
@polyester/sdk/smart-account | createPolyesterSmartAccount, createPolyesterSmartAccountClient, predictPolyesterSmartAccountAddress, sendPolyesterUserOperation |
@polyester/sdk/catalogs | createPolyesterCatalog, buildCatalogSnapshot, createCatalogSnapshotReader, patchZipperCatalogSupply, unknown-asset helpers, catalog types |
@polyester/sdk/server-session | parseSessionCookie, emptyServerSessionSnapshot, isJwtValid |
Utilities (root export)
| Function | Purpose |
|---|---|
isEvmAddress / isEvmAddressStrict / checksumEvmAddress | Address validation and EIP-55 checksumming |
evmHexToBytes / evmUtf8ToHex / evmUtf8ToBytes / keccak256Hex | Hex/byte/hash helpers |
isAbortError(err) | Detect caller-initiated aborts |
isRetryableError(err) / isResourceNotFoundError(err) / formatConnectError(err, fallback) | Error triage helpers |
columnarTimestampSecAt / expandColumnarTimestampsSec | Work with columnar time windows from chart endpoints |