Skip to main content
All Amplify SDK functions require initialization before use. Call initAmplifySDK() once at application startup.

Import

import { initAmplifySDK } from "@paxoslabs/amplify-sdk";

Usage

await initAmplifySDK("pxl_your_api_key");

Parameters

ParameterTypeRequiredDescription
apiKeystringYesYour Paxos Labs API key (format: pxl_...)
optionsSDKInitOptionsNoConfiguration options for telemetry and logging

SDKInitOptions

interface SDKInitOptions {
  /** Enable/disable PostHog telemetry (default: true) */
  telemetry?: boolean;

  /** Log level for SDK operations (default: LogLevel.ERROR) */
  logLevel?: LogLevel;

  /** Custom logger implementation */
  logger?: Logger;

  /** Target environment (default: "production") */
  environment?: Environment;
}
OptionTypeDefaultDescription
telemetrybooleantrueEnable PostHog error tracking
logLevelLogLevelLogLevel.ERRORMinimum log level to output
loggerLoggerBuilt-in console loggerCustom logger implementation
environmentEnvironment"production"Target environment ("production" or "staging")

Return Type

Promise<void>

Examples

import { initAmplifySDK } from "@paxoslabs/amplify-sdk";

await initAmplifySDK("pxl_your_api_key");

Behavior

  • Validates API key — Checks key format and minimum length
  • Returns immediately — Initialization completes without blocking on network calls
  • Populates cache in background — Vaults and assets are fetched asynchronously after init returns. Use waitForCacheReady() if you need guaranteed fast operations before the first SDK call
  • Configures telemetry — Sets up PostHog if enabled (async, non-blocking)
  • Configures logging — Sets log level and optional custom logger
  • Idempotent — Multiple calls with same key are no-ops
  • Re-initialization — Different key clears cache and reconfigures

Error Handling

try {
  await initAmplifySDK("pxl_your_api_key");
} catch (error) {
  if (error instanceof APIError) {
    console.error(`Init failed: ${error.message}`);
  }
}
Error Message PatternDescriptionResolution
"API key cannot be empty"Empty or missing API keyProvide a valid pxl_... key
"Invalid API key format"Key too short or malformedCheck key format
If you call other SDK functions (e.g., prepareDepositTxData, fetchSupportedAssets) before calling initAmplifySDK(), they will throw an SDK_NOT_INITIALIZED error. Always initialize the SDK first.