Skip to content

docs(multichain-api-middleware): add wallet-side Multichain API reference#9258

Open
adonesky1 wants to merge 11 commits into
mainfrom
add-multichain-api-reference-doc
Open

docs(multichain-api-middleware): add wallet-side Multichain API reference#9258
adonesky1 wants to merge 11 commits into
mainfrom
add-multichain-api-reference-doc

Conversation

@adonesky1

@adonesky1 adonesky1 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Explanation

@metamask/multichain-api-middleware is the implementation of MetaMask's CAIP-25 / CAIP-27 Multichain API, but it has had no prose documentation — only a stub README pointing at MIP-5. The machine-readable OpenRPC schema (@metamask/api-specs) is the source of truth but isn't easy to read, and upstream CAIP-25 has since diverged from what we implement.

This adds MULTICHAIN_API.md, a readable wallet-side reference, and links it from the package README.

It covers:

  • wallet_createSession inputs/outputs (params, result shape, examples, behavior), plus wallet_getSession, wallet_revokeSession, wallet_invokeMethod, and the wallet_sessionChanged / wallet_notify notifications.
  • Supported methods per namespace: static EVM lists (from @metamask/chain-agnostic-permission / @metamask/api-specs) vs. Snap-resolved non-EVM methods (via MultichainRoutingService.getSupportedMethods = account-Snap ∪ protocol-Snap methods).
  • The sessionProperties allowlist, including a full walkthrough of the eip1193-compatible flow (set by connect-evm / injected EIP-1193 middleware, gates the EVM network picker, backfilled by extension migration 211) and the 1.6.0 allowlist addition.
  • Error codes (5000–5302, 4100).
  • A divergence table: how MetaMask's implementation differs from the current upstream CAIP-25 (single scopes, properties/capabilities renames, bare accounts, chain-only keys, sessionId, etc.).

Behavior is described from the handler source; the doc notes that handler code is authoritative where it disagrees with the OpenRPC schema.

References

  • Companion pointer PRs in MetaMask/api-specs and MetaMask/connect-monorepo.

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've highlighted breaking changes using the "BREAKING" category above as appropriate
  • I've prepared draft pull requests for downstream packages as appropriate

Note

Low Risk
Documentation-only changes with no production code or API behavior modifications.

Overview
Adds MULTICHAIN_API.md, a wallet-side JSON-RPC reference for MetaMask’s CAIP-25 / CAIP-27 Multichain API (session methods, notifications, namespace method lists, error codes, MetaMask-specific behavior, and a divergence table vs. current upstream CAIP-25). The doc states that handler code in src/handlers/*.ts is authoritative when it disagrees with OpenRPC.

README.md gains a Documentation section linking to that file and pointing integrators at @metamask/api-specs for the machine-readable schema. CHANGELOG.md records the addition under Unreleased.

No runtime or handler code changes—documentation only.

Reviewed by Cursor Bugbot for commit fb2ec4a. Bugbot is set up for automated code reviews on this repo. Configure here.

…ence

Adds MULTICHAIN_API.md, a readable reference for the CAIP-25 / CAIP-27
Multichain API as actually implemented by this package and
@metamask/chain-agnostic-permission: wallet_createSession inputs/outputs,
the other session methods, supported methods per namespace (static EVM vs
Snap-resolved non-EVM), sessionProperties allowlist (incl. the
eip1193-compatible flow), error codes, and divergences from the current
upstream CAIP-25 spec. Links it from the package README.
@adonesky1 adonesky1 requested a review from a team as a code owner June 24, 2026 20:27
adonesky1 added 10 commits June 24, 2026 15:37
- wallet_createSession: note that at least one of requiredScopes /
  optionalScopes must resolve to a supported scope (neither -> 5100).
- Remove the standalone "eip1193-compatible session property" section; the
  allowlist table entry and version note cover it without the extra depth.
- Split error table into codes actually thrown (5100, 5302, 4100) vs codes
  defined-but-not-returned by the handler:
  - 5101/5102 are filtered out during scope bucketing, not rejected
  - 5201/5202 are a TODO and never thrown
  - 5300/5301 are schema-only; the handler never reads scopedProperties
- Fix divergence row claiming scopedProperties "errors 5300/5301" — the field
  is accepted and ignored; note this in Concepts too.
- Clarify partial-revoke is middleware (not extension-specific) behavior.
- Soften the eip1193-compatible claim: migration 211 backfills it onto
  pre-existing eip155 connections, so older Multichain-only sessions may carry it.
- Fix CAIP-25 date attribution for the optionalScopes->scopes rename (2025-07-30).
Remove scopedProperties from Concepts/intro (it's not actually implemented)
and add a dedicated bottom section explaining it was partially implemented for
EIP-3085, deprioritized, and has since been removed from the request in
upstream CAIP-25 (scopedProperties -> capabilities -> dropped). Update the
divergence row accordingly.
- Remove the standalone scopedProperties section and fold it into the
  divergence-table row.
- Apply repo oxfmt formatting (table alignment, jsonc trailing commas).
- Remove the eip1193-compatible version note and the 5100 wording note.
- Condense the "defined but not thrown" error table to a single sentence
  (keep signal: callers shouldn't expect those codes on the wire).
- Replace em dashes with colons/semicolons/parentheses throughout; oxfmt.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant