Skip to content

Commit 7ad1e57

Browse files
alexandratranjoaniekubevandanjiexiadonesky1
authored
Initial Multichain API docs (#1621)
* Initial Multichain API docs * edit content * fix typo * edits * fixes * add how-to guide and edits * minor fix * Mention multichain tag * update what's new * Apply suggestions from code review Co-authored-by: Vandan <vandan.parikh@consensys.net> * address reviewer feedback * Apply suggestions from code review Co-authored-by: Vandan <vandan.parikh@consensys.net> * Update benefits * update scope properties * minor edits * minor edit * caip-x -> caip-348 * address reviewer comments * add reference to mip-5 and mip-6 * address reviewer feedback * move what's new to may * address reviewer feedback * add extension only note * Apply suggestions from code review Co-authored-by: jiexi <jiexiluan@gmail.com> * address reviewer comments * Apply suggestions from code review Co-authored-by: Alex Donesky <alex.donesky@consensys.net> * address reviewer comment * Apply suggestions from code review Co-authored-by: Byron Gravenorst <50852695+bgravenorst@users.noreply.github.com> --------- Co-authored-by: Joan E <153745173+joaniefromtheblock@users.noreply.github.com> Co-authored-by: Vandan <vandan.parikh@consensys.net> Co-authored-by: jiexi <jiexiluan@gmail.com> Co-authored-by: Alex Donesky <alex.donesky@consensys.net> Co-authored-by: Byron Gravenorst <50852695+bgravenorst@users.noreply.github.com>
1 parent 3214817 commit 7ad1e57

File tree

8 files changed

+778
-9
lines changed

8 files changed

+778
-9
lines changed

docs/whats-new.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ of the [MetaMask developer page](https://metamask.io/developer/).
1111

1212
## May 2025
1313

14+
- Documented Multichain API [guide](/wallet/how-to/manage-networks/use-multichain),
15+
[concept](/wallet/concepts/multichain-api), and [reference](/wallet/reference/multichain-api).
16+
([#1621](https://github.com/MetaMask/metamask-docs/pull/1621))
1417
- Documented [Solana](/wallet/how-to/use-non-evm-networks/solana) dapp support via the Wallet Standard and third-party libraries.
1518
([#1940](https://github.com/MetaMask/metamask-docs/pull/1940))
1619
- Documented [MetaMask SDK + Web3Auth SDK integration](/sdk/quickstart/javascript-web3auth).

snaps/get-started/install-flask.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ sidebar_position: 1
55

66
# Install MetaMask Flask
77

8-
To get started building your own Snaps, install the MetaMask Flask browser extension on
9-
[Google Chrome](https://chromewebstore.google.com/detail/metamask-flask-developmen/ljfoeinjpaedjfecbmggjgodbgkmjkjk)
10-
or
11-
[Mozilla Firefox](https://addons.mozilla.org/en-US/firefox/addon/metamask-flask/).
8+
To build your own Snaps or test upcoming MetaMask features, install the MetaMask Flask browser
9+
extension on [Google Chrome](https://chromewebstore.google.com/detail/metamask-flask-developmen/ljfoeinjpaedjfecbmggjgodbgkmjkjk)
10+
or [Mozilla Firefox](https://addons.mozilla.org/en-US/firefox/addon/metamask-flask/).
1211

1312
Install Flask in a new browser profile, or disable any existing installed versions of MetaMask
1413
before installing Flask.
@@ -27,8 +26,10 @@ If you import accounts with funds into Flask, you do so at your own risk.
2726
## About MetaMask Flask
2827

2928
MetaMask Flask is an experimental playground that provides developers access to upcoming MetaMask features.
30-
While a small set of audited Snaps are allowlisted in the stable version of the MetaMask browser extension, MetaMask Flask is intended for developers building and testing Snaps locally or from npm.
31-
Also, new Snaps API features are enabled in Flask for testing and developer feedback before they're enabled in MetaMask stable.
29+
While a small set of audited Snaps are allowlisted in the stable version of the MetaMask browser
30+
extension, MetaMask Flask is intended for developers building and testing Snaps locally or from npm.
31+
Also, new MetaMask features are enabled in Flask for testing and developer feedback before they're
32+
enabled in MetaMask stable.
3233
These features appear in the documentation with the **Flask** or **FLASK ONLY** tag.
3334
You can also view Flask-specific features by looking for the **\[FLASK\]** label in the
3435
[MetaMask Extension changelog](https://github.com/MetaMask/metamask-extension/blob/develop/CHANGELOG.md).

wallet-sidebar.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ const sidebar = {
4141
type: "doc",
4242
label: "Add a network",
4343
id: "how-to/manage-networks/add-network"
44+
},
45+
{
46+
type: "doc",
47+
label: "Interact with multiple networks simultaneously",
48+
id: "how-to/manage-networks/use-multichain"
4449
}
4550
]
4651
},
@@ -191,6 +196,11 @@ const sidebar = {
191196
label: "About the Wallet API",
192197
id: "concepts/wallet-api"
193198
},
199+
{
200+
type: "doc",
201+
label: "About the Multichain API",
202+
id: "concepts/multichain-api"
203+
},
194204
{
195205
type: "doc",
196206
label: "Convenience libraries",
@@ -267,6 +277,11 @@ const sidebar = {
267277
label: "Ethereum provider API",
268278
id: "reference/provider-api",
269279
},
280+
{
281+
type: "doc",
282+
label: "Multichain API",
283+
id: "reference/multichain-api",
284+
},
270285
{
271286
type: "category",
272287
label: "JSON-RPC API",

wallet/concepts/multichain-api.md

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
---
2+
description: Learn about the Multichain API.
3+
---
4+
5+
# About the Multichain API
6+
7+
:::tip Experimental
8+
The Multichain API is an experimental feature and currently only available on the extension (not on mobile).
9+
:::
10+
11+
The Multichain API is a scalable, generalized web3 wallet API that supports simultaneous
12+
interactions across multiple blockchain networks and ecosystems.
13+
When integrated with [MetaMask Snaps](/snaps), it enables developers to interact with both popular
14+
and emerging networks.
15+
Key benefits include:
16+
17+
- **Elimination of chain switching** - The Multichain API allows dapps to interact with multiple networks without having to request chain switches.
18+
This feature reduces development overhead involved with ensuring the correct network is targeted for a given dapp-proposed transaction.
19+
20+
- **Extensibility** - The Multichain API can be integrated with
21+
[interoperability Snaps](https://snaps.metamask.io/explore/), providing a standards-based interface
22+
to connect wallets with dapps on non-EVM networks.
23+
24+
- **Seamless multichain UX** - The Multichain API offers improvements over EIP-1193 and [wallet-standard](https://github.com/wallet-standard/wallet-standard) interfaces.
25+
It allows dapps to create unified cross-ecosystem multichain wallet connection flows, trigger transactions across different networks more seamlessly, and clearly interpret chain-specific addresses.
26+
27+
[**Get started using the Multichain API.**](../how-to/manage-networks/use-multichain.md)
28+
29+
## Technical overview
30+
31+
The Multichain API follows the [CAIP-25](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-25.md)
32+
standard for dapps to interface with multichain wallets.
33+
See [MIP-5](https://github.com/MetaMask/metamask-improvement-proposals/blob/main/MIPs/mip-5.md) and
34+
[MIP-6](https://github.com/MetaMask/metamask-improvement-proposals/blob/main/MIPs/mip-6.md) for
35+
detailed information about MetaMask's Multichain API implementation.
36+
37+
The API includes methods for dapps to manage multichain connections:
38+
39+
- [`wallet_createSession`](../reference/multichain-api.md#wallet_createsession) - Creates a multichain connection with a wallet, with specified properties and
40+
authorization scopes.
41+
Dapps can update the connection using the same method.
42+
- [`wallet_invokeMethod`](../reference/multichain-api.md#wallet_invokemethod) - Calls a subset of the [Wallet JSON-RPC API methods](../reference/json-rpc-methods/index.md) on
43+
a specified chain.
44+
- [`wallet_getSession`](../reference/multichain-api.md#wallet_getsession) - Gets
45+
the scopes and properties of the active connection.
46+
- [`wallet_revokeSession`](../reference/multichain-api.md#wallet_revokesession) - Revokes the active connection.
47+
48+
The API also includes events that wallets can send to dapps:
49+
50+
- [`wallet_notify`](../reference/multichain-api.md#wallet_notify) - Notifies dapps of onchain events or state changes they previously subscribed to.
51+
- [`wallet_sessionChanged`](../reference/multichain-api.md#wallet_sessionchanged) - Notifies dapps of changes to the multichain connection.
52+
53+
See the [Multichain API reference](../reference/multichain-api.md) for full details.
54+
55+
### Lifecycle diagram
56+
57+
The following sequence diagram illustrates the multichain connection lifecycle.
58+
59+
```mermaid
60+
%%{
61+
init: {
62+
'sequence': {
63+
'actorMargin': 100,
64+
'width': 275
65+
}
66+
}
67+
}%%
68+
69+
sequenceDiagram
70+
participant Dapp
71+
participant Wallet
72+
participant WalletDataStore as Wallet data store
73+
74+
opt Create connection
75+
Dapp->>Wallet: wallet_createSession
76+
Wallet->>WalletDataStore: Persist connection data
77+
Wallet-->>Dapp: {"sessionScopes": {...}}
78+
end
79+
80+
opt Update connection
81+
Dapp->>Wallet: wallet_createSession (update auth)
82+
Wallet->>WalletDataStore: Update connection data
83+
Wallet-->>Dapp: {"sessionScopes": {updatedScopes...}}
84+
end
85+
86+
opt Connection interrupted with wallet-side modification
87+
Dapp-->>Wallet: Connection interrupted
88+
Wallet->>WalletDataStore: User initiated connection change
89+
Wallet-->>Dapp: wallet_sessionChanged (attempt fails)
90+
Dapp-->>Wallet: Connection re-established
91+
end
92+
93+
opt Get connection
94+
Dapp->>Wallet: wallet_getSession
95+
Wallet-->>Dapp: {"sessionScopes": {...}}
96+
end
97+
98+
opt Revoke connection
99+
Dapp->>Wallet: wallet_revokeSession
100+
Wallet->>WalletDataStore: Update connection data
101+
Wallet-->>Dapp: {"result": "true"}
102+
end
103+
```
104+
105+
## Backwards compatibility
106+
107+
When using the Multichain API, your dapp can still interact with the existing
108+
[Ethereum provider API](wallet-api.md#ethereum-provider-api).
109+
However, the provider API is not optimized for multichain usage, and we recommend
110+
[starting directly with the Multichain API](../how-to/manage-networks/use-multichain.md).
111+
The Multichain API is backwards compatible mainly to support dapps that use third-party libraries
112+
with dependencies on the legacy provider.
113+
114+
:::note
115+
A multichain connection will overwrite a connection with the legacy EIP-1193 provider, and vice versa.
116+
:::
117+
118+
## Get started
119+
120+
Get started with the Multichain API:
121+
122+
- Learn how to [use the Multichain API](../how-to/manage-networks/use-multichain.md).
123+
- See the [Multichain API reference](../reference/multichain-api.md) for more details.

wallet/concepts/wallet-api.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ This API is specified by [EIP-1193](https://eips.ethereum.org/EIPS/eip-1193), an
2222
request users' EVM accounts, read data from blockchains the user is connected to, suggest
2323
that the user sign messages and transactions, and more.
2424

25-
:::info Note
25+
:::info EIP-6963: Wallet interoperability
2626
MetaMask supports [EIP-6963](https://eips.ethereum.org/EIPS/eip-6963), which introduces an
2727
alternative wallet detection mechanism to the `window.ethereum` injected provider.
2828
This alternative mechanism enables dapps to support [wallet interoperability](wallet-interoperability.md)
@@ -46,6 +46,13 @@ The MetaMask Ethereum provider API contains the following:
4646
View the [provider API reference](../reference/provider-api.md) for all the provider properties,
4747
methods, and events.
4848

49+
:::note Multichain API
50+
MetaMask supports the [Multichain API](multichain-api.md) for interacting with multiple blockchain networks and ecosystems simultaneously.
51+
While the Multichain API is backwards compatible with the provider API, the provider API is not optimized for multichain usage.
52+
If you intend to support multichain interactions, we recommend
53+
[starting directly with the Multichain API](../how-to/manage-networks/use-multichain.md).
54+
:::
55+
4956
## JSON-RPC API
5057

5158
MetaMask uses the [`request()`](../reference/provider-api.md#request)

0 commit comments

Comments
 (0)