Skip to content

Contexts & Applications

An application is a WASM bundle installed on a node; a context is a running instance of that application’s shared state. This guide walks the lifecycle: install → create a context → join it. Everything here is on sdk.admin — see the admin API reference for the full surface.

By package@version coordinates. The node fetches the bundle from the [registry] its operator configured — you name what to install, never where from, so there is no URL to pass:

const { applicationId } = await sdk.admin.installApplication({
package: 'my-package',
version: '1.0.0',
});

To install the newest published version, ask the registry what it has. This listing is registry-side, so it takes the registry origin — unlike the install above, which uses the node’s own configured source:

// newest first
const versions = await sdk.admin.getRegistryVersions(registryUrl, 'my-package');
const app = await sdk.admin.installApplication({
package: 'my-package',
version: versions[0],
});

A 502 from installApplication means the node’s configured source has nothing published at those coordinates.

During local development, install straight from a signed .mpk path with installDevApplication({ path }).

Inspect and manage installed apps:

const { apps } = await sdk.admin.listApplications();
const app = await sdk.admin.getApplication(applicationId);
await sdk.admin.uninstallApplication(applicationId);
const { contextId, memberPublicKey } = await sdk.admin.createContext({
applicationId,
});

For a multi-service application, name the service to run:

const ctx = await sdk.admin.createContext({
applicationId,
serviceName: 'chat',
});

List and inspect contexts:

const { contexts } = await sdk.admin.getContexts(); // ContextWithGroup[]
const one = await sdk.admin.getContext(contextId); // Context
const forApp = await sdk.admin.getContextsForApplication(applicationId);
const storage = await sdk.admin.getContextStorage(contextId); // { sizeInBytes }

A context identity is your keypair within a context. Generate one, then join:

const identity = await sdk.admin.generateContextIdentity();
await sdk.admin.joinContext(contextId);
// Who's in the context?
const ids = await sdk.admin.getContextIdentities(contextId);
const mine = await sdk.admin.getContextIdentitiesOwned(contextId);

A node syncs context state peer-to-peer. You can nudge or force it:

await sdk.admin.syncContext(contextId); // request a sync
await sdk.admin.resyncContext(contextId, { force: true }); // { contextId, resyncStarted }