Skip to content

Gotchas

The short list. Each item links to the page that explains it.

  • u64, i64 and Vec<u8> travel as decimal strings and base64url, in arguments, results, record fields, errors and events. A client sends {"size": "7"}, not {"size": 7}.
  • The same types nested in another type (Vec<u64>, Option<Vec<i64>>) do not compile: wrap them in a Record or send strings (SDK macros).
  • A u64 inside your own plain serde struct reaches JSON as a number, which JavaScript may round. Use a Record, whose derive converts it; on a #[derive(AbiType)] type, give the field its D20 helper or mark it #[abi(plain)] so the ABI says it is a number (unmarked, it does not compile; SDK macros).
  • Arguments are camelCase (room_id → roomId), and unknown keys are refused (BadArgs).
  • Renaming a state field or changing its type orphans its data: an upgrade keeps the state and has no migration step (Upgrades & state).
  • A record must not also derive Serialize/Deserialize: #[derive(Record)] writes them.
  • Uniqueness belongs in the key or a unique(..) constraint, not in a check before an insert.
  • Prefer env::unique_id() to a Counter for ids.
  • A table’s size is len(), one read; iter().count() reads every record. A table stored by an older SDK counts its records on len() until its next insert or removal, and a release built with such an SDK does not keep the length: never go back to one (The length).
  • Multi-row reads are pages of at most 1,000: a view that answers a client returns one page and its next. Inside a run, iter() walks every page through one cursor (Iterating).
  • A run makes at most 10,000 writes. Use extend on a vector, map or set, not a push or insert per value: it writes the length once, so it costs half the writes (Costs and limits).
  • Vector::insert and remove rewrite every later element; use swap_remove when order does not matter, and a Set rather than Vector::contains to test membership.
  • A method with no attribute admits any signed-in account the node lets reach the app; org membership is the app’s to check with guards (Access control).
  • Take the caller from env::caller() or a guard, never from an argument.
  • #[app::error] and #[app::event] must be in the #[app::logic] module, or the ABI lists none of them. Every field needs a name: Invalid(String) does not compile, Invalid { reason: String } does.
  • Every app is in an organization (one its creator is in, or one made with it), and a cross-app call reaches only apps in the same organization.
  • A call that fails writes nothing and emits nothing; a panic is a trap, not an app error (Error handling).
  • env::xcall only queues a message: it is delivered after the entry commits, and only if the run succeeds (Cross-app calls).
  • Only views may search; a call that searches traps (Search).
  • env::fetch, actions and cross-app calls answer an error on the host target; test them with TestApp (Testing).
  • A read-only team member reaches an app’s views only: a call to any other method is refused with 403 before it runs.
  • files::open works only inside an #[app::compute] run; a call or view gets a file’s size and hash from BlobRef::info (Files and blobs).
  • An SDK 0.12 app (a WASM core module, wasm32-unknown-unknown) is refused at upload and install (400 UNSUPPORTED_BUNDLE); one left over from before answers 410 UNSUPPORTED_ENGINE. Rebuild on calimero-sdk for wasm32-wasip2 with meroctl app build.
  • Sign every release of a package with the same key: another key is another package, not an upgrade (Packaging & signing).
  • Bump #[app::state(version = N)] with every state change; meroctl app sign --previous (and meroctl app pack --previous) refuses a removed or retyped state field without it.