Skip to content

App interface (ABI)

Every app carries an ABI: a JSON description of its surface, generated by #[app::logic] at compile time and embedded in the component as the custom section calimero:abi. It is part of the component’s bytes, so it is covered by the bundle’s hash and cannot drift from the code it describes.

The node reads it to dispatch and gate calls (calimero_app_host::Abi::from_json); clients read it to learn the methods, arguments and results.

{
"abiVersion": 1,
"world": "calimero:app@0.5.7",
"state": {
"fields": { "bookings": "table", "titles": "unorderedMap", "nextId": "counter" },
"search": { "bookings": [], "nextId": [], "titles": [] },
"version": 3
},
"methods": {
"book": {
"kind": "call",
"params": [["roomId", "string"], ["start", "u64"], ["title", "string"]],
"returns": "string",
"confirm": false, "public": false, "allowSystem": false
},
"roomCount": {
"kind": "view",
"params": [["roomId", "string"]],
"returns": "u64",
"confirm": false, "public": true, "allowSystem": false
},
"releaseNoShows": {
"kind": "timer", "params": [], "returns": "option<u64>",
"every": "1m", "confirm": false, "public": false, "allowSystem": true
}
},
"errors": { "NotFound": {}, "Taken": { "start": "u64" }, "Invalid": { "reason": "string" } },
"events": { "Booked": { "id": "string", "roomId": "string", "start": "u64" } },
"types": {
"Booking": {
"kind": "record",
"fields": [["id", "string"], ["roomId", "string"], ["start", "u64"], ["title", "string"], ["checkedIn", "bool"]]
},
"Listing": { "kind": "record", "params": ["T"], "fields": [["items", "list<T>"], ["nextCursor", "option<string>"]] },
"Slot": {
"kind": "enum", "tag": "state",
"variants": [{ "name": "free" }, { "name": "held", "fields": [["booking", "Booking"]] }]
}
}
}
  • methods, by camelCase name. kind is init, call, view, timer, action or compute. params are ordered [name, type] pairs. The flags come from the method attributes: confirm, public (and rate), allowSystem, every on timers, allowApps, allowAction, compute (fuel, memoryMib, wallSecs, result) on compute methods and computeResult on their result methods. doc is the method’s /// comment, when it has one; UIs show it as the publisher’s description, and the node does not check it. A compute method’s own kind makes a node that does not know compute refuse the bundle rather than serve the method as a call.
  • state: each field’s kind, the search fields of each table, and the #[app::state(version = N)].
  • errors and events: each code or name with its fields.
  • types: the JSON shape of each app type the methods, errors and events name, and of the types those name, by the Rust type’s name: every #[derive(Record)] and every #[derive(AbiType)] serde type (SDK macros). kind is record (fields as ordered [name, type], with { "optional": true } third when the JSON may leave the field out), newtype (type), tuple (items), unit, or enum (variants, each { name }, { name, type }, { name, items } or { name, fields }, told apart as serde does: by the variant’s name as the key, by tag, by tag and content, or untagged). A generic type lists its params, which its fields name (Listing<Slot> puts Slot for T). The key is absent when no type has a shape, and a type it does not list is unknown.
  • Types: Rust integer, float and bool names, string, bytes, option<T>, list<T>, tuple<..>, unit, else the Rust type’s name. u64, i64 and bytes are strings on the wire. u64_number, i64_number and byte_list describe what plain serde writes instead (a field marked #[abi(plain)]): a JSON number and an array of byte numbers.

Every object’s keys are written in sorted order, so the same source always produces the same bytes.

The host reads abiVersion (and refuses one it does not support), the method kinds, and the flags: a view never runs as a write, confirm needs a fresh passkey assertion, public admits callers who are not signed in, allowSystem, allowApps and allowAction admit the node, other apps and the app’s own actions. Free-form keys (params, returns, doc, errors, events, types) describe the app to clients; nodes ignore them, so types came without an abiVersion bump: a node of an earlier release installs an app that carries it. A node ignores a key it does not know, at the top level and in a method, and refuses a known key whose value has the wrong shape (BadAbi), so an older node still runs an app built by a newer SDK that adds optional metadata. A field the host enforces is added only with an abiVersion bump.

  • GET /apps/{app}/abi returns an installed app’s ABI (Node API); meroctl instance abi prints it.
  • GET /apps/{app}/openapi.json returns it as an OpenAPI 3.1 document (below), under the same access.
  • mero-js and calimero-client-py read it to build typed calls; meroctl app codegen writes a typed client for an app from it in TypeScript, Python, Swift or Kotlin (Typed clients for your app).

calimero_app_abi::openapi turns an ABI into an OpenAPI 3.1 document. The node serves the one of the bundle an app runs at GET /apps/{app}/openapi.json (info.title the app’s name, info.version its bundle hash), and meroctl app codegen --lang openapi writes it for a built app.

  • One operation per method a client calls: POST /apps/{app}/methods/{name}, operationId the method’s name, tagged call or view. Init, timers, actions, compute methods, computeResult and allow(action) methods are left out: no client calls them. The node runs this route exactly as /intents (a call, or a confirm view) or /views (any other view) with the same method: the same authentication, gating, step-up and limits.
  • Request: the body of /intents or /views without method. args is the parameters by name (<Method>Args; an option<..> parameter may be left out), with idempotencyKey (and confirm on a confirm method) for a call, consistency and minIndex for a view.
  • Answer (<Method>Response): { index, result, receipt }, plus events for a call; result is typed from returns.
  • Errors: { error, message, details }, as the rest of the node API. 422 is APP_ERROR with details.code one of the app’s errors and details.fields its fields (<Code>Error), or TRAP. The ABI lists errors for the whole app, so every method documents all of them. A confirm method documents the 412 CONFIRM_REQUIRED step-up and its retry with confirm; a public one may be called without a session (security: [{}, ...]), and its rate is in x-calimero-method. The method’s doc is the operation’s x-calimero-publisher-description, kept apart from description, which states only what the node enforces.
  • Events: GET /apps/{app}/events answers text/event-stream; each frame’s event is an event’s name and data its fields (<Name>Event). An app with actions also gets the node’s ActionFailed { actionId, method, reason }.
  • Transport: every request travels inside the node’s sealed channel, so a client generated from the document needs mero-js, calimero-client-py, swift-sdk or kotlin-sdk underneath (the clients meroctl app codegen writes are built on them).

The JSON form of every ABI type, as the SDK’s macros write and read it. A 64-bit integer is a decimal string because a JavaScript number loses precision past 2^53; in stored state the same field is a CBOR integer (Tables & Collections):

ABI type JSON JSON Schema
bool true / false { "type": "boolean" }
u8, u16, u32, i8, i16, i32 number integer with the type’s minimum/maximum (format: int32 for i32)
usize, isize number integer, 32-bit range (apps run on wasm32)
u64, i64 decimal string ("18446744073709551615") string with a decimal pattern; x-calimero-type names it
u64_number, i64_number (#[abi(plain)]) number, as plain serde writes it integer with the 64-bit range; past 2^53 JavaScript loses precision
u128, i128 number, only within 64 bits integer with the 64-bit range; past 2^53 JavaScript loses precision, so prefer u64 or a string
f32, f64 number (no NaN or infinity) number, format: float / double
char a one-character string string, length 1
string string string
bytes (Vec<u8>) base64url without padding string, contentEncoding: base64url
byte_list (Vec<u8>, #[abi(plain)]) array of numbers 0..=255 array of integer
unit / returns: null null { "type": "null" }
option<T> T or null; a parameter may be left out anyOf: [T, null], not required
list<T>, Vec<T>, [T] array array of T
[T; N] array of exactly N array, minItems = maxItems = N
BTreeSet<T>, HashSet<T> array of distinct values array, uniqueItems
tuple<A, B> array [a, b] array with prefixItems
BTreeMap<K, V>, HashMap<K, V> object, keys as strings object with additionalProperties: V (integer keys get a propertyNames pattern)
Box<T>, Rc<T>, Arc<T>, &T as T as T
any other name (a record, a serde struct or enum, Page<Item>) the type’s serde form a component named after it (Page_Item): its shape from types, else any JSON

A u64, i64 or Vec<u8> nested inside another type is a compile error (SDK macros), and every app type the ABI names must derive Record or AbiType, whose fields are checked the same way, so the string forms above hold wherever these types appear; u128, i128, usize and isize do not compile at all. A #[derive(AbiType)] field marked #[abi(plain)] is described as plain serde writes it, at any depth (Vec<u64> is list<u64_number>): its JSON does not change, the ABI only says what it is. list<u8> still reads as bytes; byte_list is the array spelling. An app type with a shape in types is a component with that shape: an object with its fields, a oneOf per enum, a generic type instantiated per use (Listing_Slot). One without (any type in an ABI built before types; an app built now cannot compile one into its signatures) is an open schema (x-calimero-abi-type keeps the Rust name) and a typed client types it unknown / Any / JSONValue / JsonElement. The Swift and Kotlin clients make each described type a nested type: a record a struct / data class, an enum an enum / sealed interface coded in its serde tagging, generic where the Rust type is (Typed clients).

The Swift and Kotlin clients take the Swift or Kotlin type and write its JSON form themselves: u64 is UInt64 / ULong, i64 Int64 / Long, bytes Data / ByteArray; u64_number / i64_number are the same native types written as numbers (TypeScript number, Python int), and byte_list is [UInt8] / List<UByte> (number[], List[int]); the other integers keep their width (u32 is UInt32 / UInt, usize 32 bits, u128/i128 64 bits), char is a String, lists, sets and [T; N] are arrays / List, maps [String: V] / Map<String, V>, and tuple<A, B> a Tuple2<A, B> that is the JSON array [a, b].

meroctl app abi diff <old> <new> (each a .wasm, .mpk or ABI JSON) lists what changed and whether existing callers notice, and exits 1 on a breaking change; --json prints it as JSON. meroctl app abi show <file> prints one ABI. Parameters may widen and results narrow:

Breaking Compatible
A method a client, the node or another app calls is removed or renamed (a rename is named) A method added
kind changed (a call becomes a view, …) An option<..> parameter added
A parameter removed, added without option<..>, or changed to a type that does not hold the old values (u32 -> u64 moves from a number to a string) A parameter widened (u16 -> u32, T -> option<T>, char -> string)
A result changed to a type outside the old one (T -> option<T>, u16 -> u32) A result narrowed (option<T> -> T), or a method that returned nothing now returns a value
confirm added; public, allowSystem or an allowApps entry removed; allow(action) added The reverse of each; parameters reordered (JSON passes them by name); rate, every or compute caps changed
An error or event removed, or one of its fields removed or changed outside its old type An error, event or field added
abiVersion changed; world moved to another minor world moved to another patch
A state field removed or its collection kind changed; the state version going down or up by more than one A state field added; the state version up by one; search fields changed
A type’s shape in types changed in a way its callers notice (below) A type gaining a shape (it was any JSON)

The app types the methods, errors and events name, and the types those name, are compared by name in types, in the direction they travel in the old ABI: a type inside a parameter of a method called from outside is sent (it may widen), one inside a result, error or event is read (it may narrow), and a type used both ways must hold both. Each change is reported as type <Name>:

Change Sent Read
A field added Breaking unless callers may leave it out (option<..> or optional) Compatible
A field removed Breaking Breaking, unless it was optional
A field retyped, a variant’s payload or a tuple item retyped Compatible when it widens Compatible when it narrows
A field now optional (may be left out) Compatible Breaking
A field no longer optional Breaking, unless it is an option<..> Compatible
A variant added Compatible Breaking
A variant removed Breaking Compatible
Fields or variants reordered Compatible (an untagged enum’s variants: breaking, serde tries them in order) Compatible
The tagging style, the shape’s kind (record, enum, …), a variant’s payload kind, a tuple’s length or the number of generic parameters changed Breaking Breaking
A generic parameter renamed Compatible Compatible
The type lost its shape Breaking Breaking

Every generated client ignores a key it does not know, so a field added to what it reads is safe: TypeScript and Python read plain objects, Swift’s Decodable skips keys its type does not name, and the Kotlin client decodes with Json { ignoreUnknownKeys = true }. A variant added to what a client reads is not: a client that decodes the enum exhaustively (a Swift or Kotlin enum, a switch over a TypeScript union) has no case for it. A type the old ABI’s callers do not exchange (only an allow(action) method takes it, or nothing names it) is not compared. Recursive types (Tree holding list<Tree>) and generic ones (Page<T>, reached as Page<Item>) are compared once each.

meroctl app sign --previous <last release> (and meroctl app pack --previous) runs the same check before signing: it prints the changes, warns about breaking ones, and refuses to sign when a state field was removed or changed kind while #[app::state(version = N)] stayed the same, since the upgrade to that release would leave the app’s data unreadable (Upgrades & state).