Skip to content

Contexts & Applications

An application is a WASM bundle on a node; a context is a running instance of its shared state. This guide walks the lifecycle install → create context → join, all on mero.admin. Every method is async throws. The full surface is in the admin API reference.

By coordinates — a package name and a published version:

let installed = try await mero.admin.installApplication(
InstallApplicationRequest(package: "com.calimero.chat", version: "3.1.1")
)
let applicationId = installed.applicationId

Where the bytes come from is the node’s decision, not the caller’s: it fetches from the single registry its own [registry] config names, and accepts the download only if the blob id matches. core 0.11.0-rc.32 removed URL installs outright (core#3652), and refuses a body carrying url rather than reinterpreting it — so there is no URL form of this call to fall back to.

A node whose registry has nothing published at those coordinates answers 502 with the configured <mode> source has no application published at <pkg>@<ver>. That is retryable: the version may simply not be published yet.

To pick a version, list what the registry has (an off-node call — the node’s own listPackageVersions reports only what is installed):

let versions = try await mero.admin.getRegistryVersions(
registryUrl: registryURL, packageName: "my-package") // newest first
let app = try await mero.admin.installFromRegistry(
packageName: "my-package", version: versions[0])

List from the same registry the node installs from. If the two differ, a version this listing offers is one the node will answer 502 for.

During development, install from a path with installDevApplication(_:).

Inspect and manage:

let apps = try await mero.admin.listApplications().apps
let app = try await mero.admin.getApplication(applicationId)
_ = try await mero.admin.uninstallApplication(applicationId)
let created = try await mero.admin.createContext(
CreateContextRequest(applicationId: applicationId, groupId: groupId)
)
let contextId = created.contextId
let memberKey = created.memberPublicKey

For a multi-service application, name the service:

let ctx = try await mero.admin.createContext(
CreateContextRequest(applicationId: applicationId, groupId: groupId, serviceName: "chat")
)

List and inspect:

let contexts = try await mero.admin.getContexts().contexts // [ContextWithGroup]
let one = try await mero.admin.getContext(contextId) // Context
let forApp = try await mero.admin.getContextsForApplication(applicationId)
let storage = try await mero.admin.getContextStorage(contextId).sizeInBytes

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

let identity = try await mero.admin.generateContextIdentity() // .publicKey
_ = try await mero.admin.joinContext(contextId)
let all = try await mero.admin.getContextIdentities(contextId).identities
let mine = try await mero.admin.getContextIdentitiesOwned(contextId).identities
r.resyncStarted
try await mero.admin.syncContext(contextId) // request a sync
let r = try await mero.admin.resyncContext(contextId, request: ResyncContextRequest(force: true))