SettleMint
API referenceTypeScript SDK

TypeScript SDK

A typed, namespaced client for every v2 route, generated from the platform's own declaration, with TanStack Query factories and a matching Effect surface.

Overview

The DALP TypeScript SDK is one object shaped like the Platform API. dalp.api.token.list(), dalp.api.token.transfer({ assetId: tokenAddress, transfers }), dalp.api.party.users.me(). Every route the platform declares is reachable that way, typed end to end.

The SDK and OpenAPI contract are generated from the same route declaration for a release. Match the SDK version to the deployment version: a newer client can name a route an older deployment does not serve.

One declaration feeds the client, its types, and the CLI.The platform's route declaration is the single source. Generation reads it once and emits two artifacts: a route table carrying each route's path, method, and settlement behaviour, and a type registry keyed by route id carrying each route's request and response types. Three consumers are built from those artifacts rather than maintained by hand: the namespaced promise client a browser or server application calls, the Effect client with the same routes and a typed failure channel, and the command-line interface. Because all three read the same two artifacts, a route the platform adds or changes reaches every one of them through regeneration, and their route definitions match the release used to generate them.One declaration feeds the client, its types, and the CLI.The platform's route declaration is the single source. Generation emits a route table of paths, methods, and settlement behaviour, and a type registry keyed by route id. The promise client, the Effect client, and the command-line interface are all built from those two artifacts, so a route the platform adds reaches every one of them through regeneration.

The declaration is read once and emits a route table and a type registry. The promise client, the Effect client, and the CLI are generated from those two artifacts, so their definitions share one source for that release.

The SDK runs anywhere a modern JavaScript runtime does. In a browser it authenticates with the session cookie; on a server it authenticates with an API key, and it refuses the second combination in the first place. It has no framework dependency: React, TanStack Start, Next.js, a plain Node service, and a worker all use the same client, and the framework-shaped conveniences are opt-in.

Read this family if you are building against the Platform API in TypeScript. Calling the API from another language, or after the endpoint schemas themselves, the API reference has the spec-rendered routes and the integration guides cover the header contracts every client shares.

Install the package, construct a client, and pick the credential that matches where your code runs.

How a route call is shaped, what comes back, and how paging, filtering, and caching work.

Writes: retry safety, on-chain settlement, the acting context headers, and the errors you must handle.

Routes that push a sequence of events instead of returning one body.

Query and mutation factories, cache keys, and invalidation after a write.

Build a browser app with user sessions: keep host-only cookies on your app origin with createDalpProxy.

Server-side rendering in TanStack Start and Next.js: where the client lives, how the session travels, and what to hydrate.

The Effect surface: the same routes returning Effect values instead of promises.

Settlement, credentials, and caching

Three SDK behaviors affect application design: writes can remain pending, browser clients reject API keys, and query factories derive cache keys.

A write can resolve before the chain does. dalp.api.token.transfer(...) asks the platform to wait for a bounded time, set through settlementTimeoutMs. The call returns either the settled record or a handle for an instruction still in progress. A handle is not a failed write, and treating it as one tells a user their transfer was rejected while it is still in flight. Mutations and settlement covers both shapes and how to follow a handle.

An API key cannot reach a browser. Constructing a browser client with a key throws at construction rather than at the first request. A key carries the full authority of the identity it belongs to, and a key in a browser bundle is readable by every visitor, so the check is deliberately the loudest thing in the constructor. Install and configure covers which credential belongs where.

Cache keys are derived, not written. queryOptions builds its key from route identity plus canonicalized input, so two callers passing the same parameters in different key order share one cache entry. Hand-written keys are where cache bugs come from: one character of difference is a second entry that never invalidates, and a collision is one entry serving two things. TanStack Query covers the key shape and invalidation.

What the SDK is not

It is not a validation library. The platform validates every request on the way in and every response on the way out. The SDK checks each success response against the route's declared response and throws sdk.response.MALFORMED_SUCCESS on a mismatch; it loads those response schemas on the first call rather than at import, and it does not validate input. Validating user input before you send it stays your choice of library, and the Console's own approach is one worked example.

The SDK is not a state manager either. It returns promises and, for the routes that stream, async iterables. The TanStack Query factories are plain objects in the shapes that library expects, so nothing forces you into it and nothing stops you using something else.

The installed SDK includes the routes declared for its release. Upgrade the SDK when you adopt routes added by a newer platform release.

On this page