-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
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 3eff634
Merge branch 'main' into 1566-multichain
alexandratran 5d85f55
Merge branch 'main' into 1566-multichain
alexandratran f1d72dc
edit content
alexandratran 3ef9258
Merge branch 'main' into 1566-multichain
alexandratran d06c36f
fix typo
alexandratran 45a7748
Merge branch 'main' into 1566-multichain
alexandratran f984b7d
edits
alexandratran e72193e
Merge branch 'main' into 1566-multichain
alexandratran 6eee68f
Merge branch 'main' into 1566-multichain
joaniekube 4be0757
Merge branch 'main' into 1566-multichain
alexandratran 66b29ae
Merge branch '1566-multichain' of github.com:MetaMask/metamask-docs i…
alexandratran f83c96f
fixes
alexandratran ace1a08
Merge branch 'main' into 1566-multichain
alexandratran e752569
add how-to guide and edits
alexandratran 9f3c5ba
minor fix
alexandratran 290b796
Merge branch 'main' into 1566-multichain
alexandratran 1fec541
Mention multichain tag
alexandratran 118b981
update what's new
alexandratran 19df454
Apply suggestions from code review
alexandratran 4574202
Merge branch 'main' into 1566-multichain
alexandratran 0d39c1b
address reviewer feedback
alexandratran 6397c3d
Apply suggestions from code review
alexandratran 401b459
Merge branch 'main' into 1566-multichain
alexandratran 43424e0
Merge branch 'main' into 1566-multichain
alexandratran 7a6a8e0
Update benefits
alexandratran 35874e5
Merge branch 'main' into 1566-multichain
alexandratran 8b8828e
update scope properties
alexandratran a4f386a
minor edits
alexandratran 93a8cc6
minor edit
alexandratran cae4eac
Merge branch 'main' into 1566-multichain
alexandratran 0c6712c
caip-x -> caip-348
alexandratran 8ace53c
Merge branch 'main' into 1566-multichain
alexandratran 10b6666
Merge branch 'main' into 1566-multichain
alexandratran 3b0ff4a
address reviewer comments
alexandratran 2ec7900
Merge branch 'main' into 1566-multichain
alexandratran 4e8d23d
add reference to mip-5 and mip-6
alexandratran 689b63c
Merge branch 'main' into 1566-multichain
alexandratran b6fc33e
address reviewer feedback
alexandratran 6c96517
move what's new to may
alexandratran e1b2387
Merge branch 'main' into 1566-multichain
alexandratran ff77348
address reviewer feedback
alexandratran d281591
Merge branch 'main' into 1566-multichain
alexandratran fcaef43
add extension only note
alexandratran d03d3c3
Apply suggestions from code review
alexandratran 227a59e
address reviewer comments
alexandratran e39086d
Apply suggestions from code review
alexandratran bf4aa6d
address reviewer comment
alexandratran 4f9afe5
Apply suggestions from code review
alexandratran f00169c
Merge branch 'main' into 1566-multichain
alexandratran 153eb34
Merge branch 'main' into 1566-multichain
alexandratran File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
|
||
|
||
:::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 | ||
jiexi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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 | ||
alexandratran marked this conversation as resolved.
Show resolved
Hide resolved
|
||
[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. | ||
alexandratran marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
:::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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.