Skip to content

RPC client

mero.rpc (RpcClient) calls the methods a context’s WASM application exposes, over the node’s /jsonrpc endpoint. It shares the SDK’s transport, so authentication, refresh, and the error model apply. A contract-level failure surfaces as MeroError.rpc(RpcError).

See the executing methods guide for task-oriented examples.

func execute<T: Decodable>(
contextId: String,
method: String,
argsJson: [String: JSONValue] = [:],
executorPublicKey: String? = nil
) async throws -> T

Calls method on the application in contextId and decodes result.output into T. argsJson is a [String: JSONValue] map (JSONValue is ExpressibleBy…Literal, so ["id": "42", "n": 3] works). A JSON-RPC error object is mapped to MeroError.rpc(RpcError).

struct Post: Decodable { let id: String; let title: String }
let post: Post = try await mero.rpc.execute(
contextId: contextId,
method: "get_post",
argsJson: ["id": "42"]
)

migrateMyEntries(_ contextId:) -> MigrateMyEntriesSummary

Section titled “migrateMyEntries(_ contextId:) -> MigrateMyEntriesSummary”

Owner-driven migration: re-signs the caller’s identity-gated entries to the current schema in a single sweep (it does not loop). Returns the counts.

public struct MigrateMyEntriesSummary: Codable, Sendable, Equatable {
public let converted: Int // entries re-signed this call
public let remaining: Int // still below the target schema
}
let summary = try await mero.rpc.migrateMyEntries(contextId)

Read-only count of the caller’s entries still below the target schema — decide whether to migrate, or show progress.

let pending = try await mero.rpc.countMyPending(contextId)
if pending > 0 { _ = try await mero.rpc.migrateMyEntries(contextId) }