Skip to content
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

Initial Multichain API docs #1621

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 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
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
5 changes: 4 additions & 1 deletion docs/whats-new.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ The latest major MetaMask documentation updates are listed by the month they wer
For a comprehensive list of recent product changes, visit the "Release Notes" section at the bottom
of the [MetaMask developer page](https://metamask.io/developer/).

## February
## February 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 [Unichain Mainnet](/services/reference/unichain) support.([#1878](https://github.com/MetaMask/metamask-docs/pull/1878))

## January 2025
Expand Down
14 changes: 14 additions & 0 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,20 @@ const config = {
editUrl: "https://github.com/MetaMask/metamask-docs/edit/main/",
sidebarPath: require.resolve("./wallet-sidebar.js"),
breadcrumbs: false,
admonitions: {
keywords: [
"info",
"success",
"danger",
"note",
"tip",
"warning",
"important",
"caution",
"security",
"flaskOnly",
],
},
sidebarItemsGenerator: async function ({ defaultSidebarItemsGenerator, ...args }) {
const sidebarItems = await defaultSidebarItemsGenerator(args);
const dynamicItems = await fetchAndGenerateDynamicSidebarItems(
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",
id: "how-to/manage-networks/use-multichain"
}
]
},
Expand Down Expand Up @@ -177,6 +182,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 @@ -253,6 +263,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
116 changes: 116 additions & 0 deletions wallet/concepts/multichain-api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
---
description: Learn about the Multichain API.
sidebar_custom_props:
flask_only: true
---

# About the Multichain API

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

View workflow job for this annotation

GitHub Actions / Lint / 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": 7, "column": 3}}}, "severity": "WARNING"}

:::flaskOnly
:::

The Multichain API is a scalable, generalized web3 wallet API that supports simultaneous
interactions across multiple blockchain networks.
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 EVM networks without having to request chain switches.
This feature significantly reduces development overhead involved with error handling.

- **Extensibility** - The Multichain API can be integrated with
[interoperability Snaps](https://snaps.metamask.io/explore/), providing a standards-based interface
to non-EVM networks that can be broadly adopted across ecosystems.

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

View workflow job for this annotation

GitHub Actions / Lint / Spelling (.md)

[vale] reported by reviewdog 🐶 [Microsoft.Adverbs] Remove 'broadly' if it's not important to the meaning of the statement. Raw Output: {"message": "[Microsoft.Adverbs] Remove 'broadly' if it's not important to the meaning of the statement.", "location": {"path": "wallet/concepts/multichain-api.md", "range": {"start": {"line": 23, "column": 35}}}, "severity": "WARNING"}

- **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 multichain wallet connection flows, trigger transactions across disparate networks, 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.
The API includes a method [`wallet_createSession`](../reference/multichain-api.md#wallet_createsession)
that dapps can call to create a multichain connection with a wallet, with specified properties and
authorization scopes.
Dapps can update the connection using the same method `wallet_createSession`.

Dapps can use [`wallet_invokeMethod`](../reference/multichain-api.md#wallet_invokemethod) to
call a subset of the [Wallet JSON-RPC API methods](../reference/json-rpc-methods/index.md) on
a specified chain.
Dapps can use [`wallet_getSession`](../reference/multichain-api.md#wallet_getsession) to get
the scopes and properties of the active connection, and use
[`wallet_revokeSession`](../reference/multichain-api.md#wallet_revokesession) to revoke the connection.
The API also supports the following events:

- [`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 Ethereum Provider API is not optimized for multichain usage, and we recommend
[starting directly with the Multichain API](../how-to/manage-networks/use-multichain.md) if possible.
The Multichain API is backwards compatible mainly to support dapps that use third-party libraries
with dependencies on the legacy provider.

## 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.
Loading
Loading