Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
79b421d
Initial Multichain API docs
alexandratran Oct 9, 2024
3eff634
Merge branch 'main' into 1566-multichain
alexandratran Oct 9, 2024
5d85f55
Merge branch 'main' into 1566-multichain
alexandratran Oct 11, 2024
f1d72dc
edit content
alexandratran Oct 11, 2024
3ef9258
Merge branch 'main' into 1566-multichain
alexandratran Oct 11, 2024
d06c36f
fix typo
alexandratran Oct 15, 2024
45a7748
Merge branch 'main' into 1566-multichain
alexandratran Oct 22, 2024
f984b7d
edits
alexandratran Oct 22, 2024
e72193e
Merge branch 'main' into 1566-multichain
alexandratran Oct 22, 2024
6eee68f
Merge branch 'main' into 1566-multichain
joaniekube Oct 28, 2024
4be0757
Merge branch 'main' into 1566-multichain
alexandratran Oct 31, 2024
66b29ae
Merge branch '1566-multichain' of github.com:MetaMask/metamask-docs i…
alexandratran Oct 31, 2024
f83c96f
fixes
alexandratran Oct 31, 2024
ace1a08
Merge branch 'main' into 1566-multichain
alexandratran Nov 8, 2024
e752569
add how-to guide and edits
alexandratran Nov 8, 2024
9f3c5ba
minor fix
alexandratran Nov 12, 2024
290b796
Merge branch 'main' into 1566-multichain
alexandratran Nov 13, 2024
1fec541
Mention multichain tag
alexandratran Nov 13, 2024
118b981
update what's new
alexandratran Nov 13, 2024
19df454
Apply suggestions from code review
alexandratran Nov 25, 2024
4574202
Merge branch 'main' into 1566-multichain
alexandratran Nov 25, 2024
0d39c1b
address reviewer feedback
alexandratran Nov 25, 2024
6397c3d
Apply suggestions from code review
alexandratran Feb 6, 2025
401b459
Merge branch 'main' into 1566-multichain
alexandratran Feb 6, 2025
7a6aec0
feat: add multichain client docs
chakra-guy Feb 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
edits
  • Loading branch information
alexandratran committed Oct 22, 2024
commit f984b7d44c584fbf358943fc80e4e3b4d368c07b
14 changes: 14 additions & 0 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,20 @@ const config = {
routeBasePath: "wallet",
sidebarPath: require.resolve("./wallet-sidebar.js"),
breadcrumbs: false,
admonitions: {
keywords: [
"info",
"success",
"danger",
"note",
"tip",
"warning",
"important",
"caution",
"security",
"flaskOnly",
],
},
editUrl: "https://github.com/MetaMask/metamask-docs/edit/main/",
remarkPlugins: [
[
Expand Down
2 changes: 1 addition & 1 deletion wallet-sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ const sidebar = {
},
{
type: "doc",
id: "reference/multichain-api-events",
id: "reference/multichain-api",
},
],
collapsed: false,
Expand Down
86 changes: 17 additions & 69 deletions wallet/concepts/multichain-api.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
description: Learn about the MetaMask Multichain API.
sidebar_position: 4
sidebar_custom_props:
flask_only: true
---

# About the Multichain API

:::warning Developer preview
This is a developer preview of the Multichain API.
It is only available in [MetaMask Flask](/snaps/get-started/install-flask).
:::flaskOnly
:::

The Multichain API is a scalable, generalized web3 wallet API that supports simultaneous
Expand All @@ -32,24 +32,25 @@ Key benefits include:

The Multichain API follows the [CAIP-25](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-25.md)
standard for dapps to interface with multichain wallets.
The API includes a method [`wallet_createSession`](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-25.md)
The API includes a method [`wallet_createSession`](../reference/multichain-api.md#wallet_createsession)
that dapps can call to create a multichain session with a wallet, with specified properties and
authorization scopes.
The session can be created with or without a `sessionId`, and can be updated using the same method
`wallet_createSession`.
Dapps can update the session using the same method `wallet_createSession`.

Dapps can use the method [`wallet_invokeMethod`](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-27.md)
to call a subset of the [Wallet JSON-RPC API methods](/wallet/reference/json-rpc-api) on a specified chain.
Dapps can use [`wallet_getSession`](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-312.md)
to get the scope of the current session, and
[`wallet_revokeSession`](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-285.md) to
revoke the current session.
The API also supports [events](../reference/multichain-api-events.md), allowing wallets to notify
dapps of changes to a session.
Dapps can use [`wallet_invokeMethod`](../reference/multichain-api.md#wallet_invokemethod) to call a
subset of the [Wallet JSON-RPC API methods](/wallet/reference/json-rpc-api) on a specified chain.
Dapps can use [`wallet_getSession`](../reference/multichain-api.md#wallet_getsession) to get the
scopes and properties of the active session, and use [`wallet_revokeSession`](../reference/multichain-api.md#wallet_revokesession)
to revoke the session.
The API also supports the [`wallet_notify`](../reference/multichain-api.md#wallet_notify) and
[`wallet_sessionChanged`](../reference/multichain-api.md#wallet_sessionchanged) events, allowing
wallets to notify dapps of changes to the session.

The following sequence diagrams illustrate the multichain session lifecycle without and with a `sessionId`.
See the [Multichain API reference](../reference/multichain-api.md) for full details.

### Lifecycle without a `sessionId`
### Lifecycle diagram

The following sequence diagram illustrates the multichain session lifecycle.

```mermaid
%%{
Expand Down Expand Up @@ -96,56 +97,3 @@ sequenceDiagram
Wallet-->>Dapp: {"result": "true"}
end
```

### Lifecycle with a `sessionId`

```mermaid
%%{
init: {
'sequence': {
'actorMargin': 75,
'width': 200
}
}
}%%

sequenceDiagram
participant DappDataStore as Dapp data store
participant Dapp
participant Wallet
participant WalletDataStore as Wallet data store

opt Create session
Dapp->>Wallet: wallet_createSession
Wallet->>WalletDataStore: Persist session data
Wallet-->>Dapp: {"sessionId": "0xdeadbeef", "sessionScopes": {...}}
Dapp->>DappDataStore: Persist session data
end

opt Update session
Dapp->>Wallet: wallet_createSession (sessionId: 0xdeadbeef, {updatedScopes...})
Wallet->>WalletDataStore: Update session data
Wallet-->>Dapp: {"sessionId": "0xdeadbeef", "sessionScopes": {(updated)sessionScopes...}}
Dapp->>DappDataStore: Persist session data
end

opt User initiated session change
Wallet->>WalletDataStore: User initiated session change
Wallet-->>Dapp: wallet_sessionChanged (sessionId: 0xdeadbeef)
Dapp->>DappDataStore: Update session data
end

opt Revoke session
Dapp->>Wallet: wallet_createSession (sessionId: 0xnewbeef, no scopes)
Wallet->>WalletDataStore: Create new, empty session 0xnewbeef, clear all older sessions with the same dapp
Wallet-->>Dapp: {"result": "true"} (session is revoked)
Dapp->>DappDataStore: Clear session data
end

alt Revoke session (alternate)
Dapp->>Wallet: wallet_revokeSession (sessionId: 0xdeadbeef)
Wallet->>WalletDataStore: Update session data
Wallet-->>Dapp: {"result": "true"} (session is revoked)
Dapp->>DappDataStore: Update session data
end
```
88 changes: 0 additions & 88 deletions wallet/reference/multichain-api-events.md

This file was deleted.

Loading