Skip to main content
Install @paxoslabs/amplify-sdk@1.0.0, instantiate AmplifyClient once, and call its subclient methods.

Requirements

  • Node.js >= 24
  • An API key from Paxos Labs
The SDK has no required peer dependencies. Most consumers also install viem (and optionally wagmi) to sign and broadcast the transactions the SDK returns.

Install

Optional signing / wallet libraries

These are not pulled in by the SDK, but you’ll typically install them in the consumer:

Get an API key

API keys are issued through the Paxos Labs onboarding process — contact your Paxos Labs representative if you don’t have one yet. Store the secret in a server-side environment variable; never bundle it into a browser.

Instantiate the client

Construct an AmplifyClient once and reuse it across requests on a server.
The lazy-singleton pattern throws a clear error at first use instead of at module load, which is friendlier in build environments where the secret may be absent.

Constructor options

The SDK defaults to production (AmplifyEnvironment.Production). You only need to pass environment or baseUrl for non-production use cases.

Server-side vs. client-side usage

The API key authenticates every call and must not ship to the browser. The recommended pattern is:
  1. Browser code calls your own backend (a Next.js Route Handler, a Server Action, an Express route, etc.).
  2. Your backend constructs the AmplifyClient, calls the SDK, and returns the prepared { to, data, value } payload.
  3. Browser code signs and broadcasts the transaction with the user’s wallet (wagmi / viem / Privy / Dynamic / etc.).

Next.js Route Handler

Browser-side submission

First call

A quick smoke test to confirm your key works:
If the key is invalid or the request fails, the SDK throws AmplifyError (see Errors).

Response format

By default, prepare* and cancel calls return ABI-encoded calldata only:
Pass responseFormat: 'full' if you want the ABI fragment, function name, and args alongside the encoded calldata — useful when you want to re-encode in your own ABI plumbing or render the call in a UI.

Decimals

The SDK accepts and returns token amounts as base-units decimal strings. It never parses human-readable inputs. Convert before calling:
Always read decimals() live from the token contract (e.g. via viem’s readContract or wagmi’s useBalance).

Errors

Every method throws AmplifyError on non-2xx responses, network failures, and serialization errors. Timeouts throw AmplifyTimeoutError.

Next steps