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.

From a hosted bundle URL:

let installed = try await mero.admin.installApplication(
InstallApplicationRequest(url: "https://example.com/app.wasm", hash: nil, metadata: [])
)
let applicationId = installed.applicationId

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

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

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))