Skip to content

Initial Multichain API docs #1621

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 51 commits into from
May 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 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
43424e0
Merge branch 'main' into 1566-multichain
alexandratran Feb 14, 2025
7a6a8e0
Update benefits
alexandratran Feb 14, 2025
35874e5
Merge branch 'main' into 1566-multichain
alexandratran Mar 5, 2025
8b8828e
update scope properties
alexandratran Mar 5, 2025
a4f386a
minor edits
alexandratran Mar 5, 2025
93a8cc6
minor edit
alexandratran Mar 5, 2025
cae4eac
Merge branch 'main' into 1566-multichain
alexandratran Apr 15, 2025
0c6712c
caip-x -> caip-348
alexandratran Apr 15, 2025
8ace53c
Merge branch 'main' into 1566-multichain
alexandratran Apr 18, 2025
10b6666
Merge branch 'main' into 1566-multichain
alexandratran Apr 21, 2025
3b0ff4a
address reviewer comments
alexandratran Apr 22, 2025
2ec7900
Merge branch 'main' into 1566-multichain
alexandratran Apr 22, 2025
4e8d23d
add reference to mip-5 and mip-6
alexandratran Apr 22, 2025
689b63c
Merge branch 'main' into 1566-multichain
alexandratran Apr 30, 2025
b6fc33e
address reviewer feedback
alexandratran Apr 30, 2025
6c96517
move what's new to may
alexandratran Apr 30, 2025
e1b2387
Merge branch 'main' into 1566-multichain
alexandratran May 1, 2025
ff77348
address reviewer feedback
alexandratran May 1, 2025
d281591
Merge branch 'main' into 1566-multichain
alexandratran May 15, 2025
fcaef43
add extension only note
alexandratran May 15, 2025
d03d3c3
Apply suggestions from code review
alexandratran May 16, 2025
227a59e
address reviewer comments
alexandratran May 16, 2025
e39086d
Apply suggestions from code review
alexandratran May 17, 2025
bf4aa6d
address reviewer comment
alexandratran May 17, 2025
4f9afe5
Apply suggestions from code review
alexandratran May 18, 2025
f00169c
Merge branch 'main' into 1566-multichain
alexandratran May 18, 2025
153eb34
Merge branch 'main' into 1566-multichain
alexandratran May 28, 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
3 changes: 3 additions & 0 deletions docs/whats-new.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ of the [MetaMask developer page](https://metamask.io/developer/).

## May 2025

- Documented Multichain API [guide](/wallet/how-to/manage-networks/use-multichain),
[concept](/wallet/concepts/multichain-api), and [reference](/wallet/reference/multichain-api).
([#1621](https://github.com/MetaMask/metamask-docs/pull/1621))
- Documented [Solana](/wallet/how-to/use-non-evm-networks/solana) dapp support via the Wallet Standard and third-party libraries.
([#1940](https://github.com/MetaMask/metamask-docs/pull/1940))
- Documented [MetaMask SDK + Web3Auth SDK integration](/sdk/quickstart/javascript-web3auth).
Expand Down
13 changes: 7 additions & 6 deletions snaps/get-started/install-flask.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ sidebar_position: 1

# Install MetaMask Flask

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

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

MetaMask Flask is an experimental playground that provides developers access to upcoming MetaMask features.
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.
Also, new Snaps API features are enabled in Flask for testing and developer feedback before they're enabled in MetaMask stable.
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.
Also, new MetaMask features are enabled in Flask for testing and developer feedback before they're
enabled in MetaMask stable.
These features appear in the documentation with the **Flask** or **FLASK ONLY** tag.
You can also view Flask-specific features by looking for the **\[FLASK\]** label in the
[MetaMask Extension changelog](https://github.com/MetaMask/metamask-extension/blob/develop/CHANGELOG.md).
15 changes: 15 additions & 0 deletions wallet-sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ const sidebar = {
type: "doc",
label: "Add a network",
id: "how-to/manage-networks/add-network"
},
{
type: "doc",
label: "Interact with multiple networks simultaneously",
id: "how-to/manage-networks/use-multichain"
}
]
},
Expand Down Expand Up @@ -191,6 +196,11 @@ const sidebar = {
label: "About the Wallet API",
id: "concepts/wallet-api"
},
{
type: "doc",
label: "About the Multichain API",
id: "concepts/multichain-api"
},
{
type: "doc",
label: "Convenience libraries",
Expand Down Expand Up @@ -267,6 +277,11 @@ const sidebar = {
label: "Ethereum provider API",
id: "reference/provider-api",
},
{
type: "doc",
label: "Multichain API",
id: "reference/multichain-api",
},
{
type: "category",
label: "JSON-RPC API",
Expand Down
123 changes: 123 additions & 0 deletions wallet/concepts/multichain-api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
---
description: Learn about the Multichain API.
---

# About the Multichain API

Check warning on line 5 in wallet/concepts/multichain-api.md

View workflow job for this annotation

GitHub Actions / Spelling (.md)

[vale] reported by reviewdog 🐶 [Consensys.Headings] 'About the Multichain API' should use sentence-style capitalization. Raw Output: {"message": "[Consensys.Headings] 'About the Multichain API' should use sentence-style capitalization.", "location": {"path": "wallet/concepts/multichain-api.md", "range": {"start": {"line": 5, "column": 3}}}, "severity": "WARNING"}

Check warning on line 5 in wallet/concepts/multichain-api.md

View workflow job for this annotation

GitHub Actions / Spelling (.mdx)

[vale] reported by reviewdog 🐶 [Consensys.Headings] 'About the Multichain API' should use sentence-style capitalization. Raw Output: {"message": "[Consensys.Headings] 'About the Multichain API' should use sentence-style capitalization.", "location": {"path": "wallet/concepts/multichain-api.md", "range": {"start": {"line": 5, "column": 3}}}, "severity": "WARNING"}

:::tip Experimental
The Multichain API is an experimental feature and currently only available on the extension (not on mobile).
:::

The Multichain API is a scalable, generalized web3 wallet API that supports simultaneous
interactions across multiple blockchain networks and ecosystems.
When integrated with [MetaMask Snaps](/snaps), it enables developers to interact with both popular
and emerging networks.
Key benefits include:

- **Elimination of chain switching** - The Multichain API allows dapps to interact with multiple networks without having to request chain switches.
This feature reduces development overhead involved with ensuring the correct network is targeted for a given dapp-proposed transaction.

- **Extensibility** - The Multichain API can be integrated with
[interoperability Snaps](https://snaps.metamask.io/explore/), providing a standards-based interface
to connect wallets with dapps on non-EVM networks.

- **Seamless multichain UX** - The Multichain API offers improvements over EIP-1193 and [wallet-standard](https://github.com/wallet-standard/wallet-standard) interfaces.
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.

[**Get started using the Multichain API.**](../how-to/manage-networks/use-multichain.md)

## Technical overview

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.
See [MIP-5](https://github.com/MetaMask/metamask-improvement-proposals/blob/main/MIPs/mip-5.md) and
[MIP-6](https://github.com/MetaMask/metamask-improvement-proposals/blob/main/MIPs/mip-6.md) for
detailed information about MetaMask's Multichain API implementation.

The API includes methods for dapps to manage multichain connections:

- [`wallet_createSession`](../reference/multichain-api.md#wallet_createsession) - Creates a multichain connection with a wallet, with specified properties and
authorization scopes.
Dapps can update the connection using the same method.
- [`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
a specified chain.
- [`wallet_getSession`](../reference/multichain-api.md#wallet_getsession) - Gets
the scopes and properties of the active connection.
- [`wallet_revokeSession`](../reference/multichain-api.md#wallet_revokesession) - Revokes the active connection.

The API also includes events that wallets can send to dapps:

- [`wallet_notify`](../reference/multichain-api.md#wallet_notify) - Notifies dapps of onchain events or state changes they previously subscribed to.
- [`wallet_sessionChanged`](../reference/multichain-api.md#wallet_sessionchanged) - Notifies dapps of changes to the multichain connection.

See the [Multichain API reference](../reference/multichain-api.md) for full details.

### Lifecycle diagram

The following sequence diagram illustrates the multichain connection lifecycle.

```mermaid
%%{
init: {
'sequence': {
'actorMargin': 100,
'width': 275
}
}
}%%

sequenceDiagram
participant Dapp
participant Wallet
participant WalletDataStore as Wallet data store

opt Create connection
Dapp->>Wallet: wallet_createSession
Wallet->>WalletDataStore: Persist connection data
Wallet-->>Dapp: {"sessionScopes": {...}}
end

opt Update connection
Dapp->>Wallet: wallet_createSession (update auth)
Wallet->>WalletDataStore: Update connection data
Wallet-->>Dapp: {"sessionScopes": {updatedScopes...}}
end

opt Connection interrupted with wallet-side modification
Dapp-->>Wallet: Connection interrupted
Wallet->>WalletDataStore: User initiated connection change
Wallet-->>Dapp: wallet_sessionChanged (attempt fails)
Dapp-->>Wallet: Connection re-established
end

opt Get connection
Dapp->>Wallet: wallet_getSession
Wallet-->>Dapp: {"sessionScopes": {...}}
end

opt Revoke connection
Dapp->>Wallet: wallet_revokeSession
Wallet->>WalletDataStore: Update connection data
Wallet-->>Dapp: {"result": "true"}
end
```

## Backwards compatibility

When using the Multichain API, your dapp can still interact with the existing
[Ethereum provider API](wallet-api.md#ethereum-provider-api).
However, the provider API is not optimized for multichain usage, and we recommend
[starting directly with the Multichain API](../how-to/manage-networks/use-multichain.md).
The Multichain API is backwards compatible mainly to support dapps that use third-party libraries
with dependencies on the legacy provider.

:::note
A multichain connection will overwrite a connection with the legacy EIP-1193 provider, and vice versa.
:::

## Get started

Get started with the Multichain API:

- Learn how to [use the Multichain API](../how-to/manage-networks/use-multichain.md).
- See the [Multichain API reference](../reference/multichain-api.md) for more details.
9 changes: 8 additions & 1 deletion wallet/concepts/wallet-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ This API is specified by [EIP-1193](https://eips.ethereum.org/EIPS/eip-1193), an
request users' EVM accounts, read data from blockchains the user is connected to, suggest
that the user sign messages and transactions, and more.

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

:::note Multichain API
MetaMask supports the [Multichain API](multichain-api.md) for interacting with multiple blockchain networks and ecosystems simultaneously.
While the Multichain API is backwards compatible with the provider API, the provider API is not optimized for multichain usage.
If you intend to support multichain interactions, we recommend
[starting directly with the Multichain API](../how-to/manage-networks/use-multichain.md).
:::

## JSON-RPC API

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