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.

From a URL (a hosted .wasm/.mpk bundle):

const { applicationId } = await sdk.admin.installApplication({
url: 'https://example.com/app.wasm',
hash: '…', // optional integrity hash
metadata: [], // bytes; [] for none
});

From a registry package — the SDK resolves the manifest, derives the bundle artifact URL, and installs it:

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

During local development, install straight from a path with installDevApplication({ path, metadata: [] }).

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 }