You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: align MetaMask Connect docs with current SDK package APIs (#2959)
* docs: update MetaMask Connect v2 guides & API
Update docs for MetaMask Connect v2: document that @metamask/connect-evm and @metamask/connect-solana now require explicit @metamask/connect-multichain peer installation; update installation quickstarts and notes. Clarify client behaviors (async createEVMClient/createMultichainClient, singleton merging semantics and that the initial dapp object is never overwritten), add guidance on session restoration (wallet_sessionChanged) and forceRequest option for connect. Revise provider and JSON-RPC notes: provider auto-announcement (EIP-6963) with skipAutoAnnounce, new error codes (-32002, 4902, 1013), eth_coinbase returns a single address, and wallet_requestPermissions result shape. Misc: move/rename options (analytics.enabled, skipAutoAnnounce, ui.showInstallModal, debug), Solana changes (solana_signMessage + .signature result, testnet/devnet availability in extension only), polyfill notes for Event when using wagmi, and other small clarity/formatting fixes across reference and quickstart files.
* Docs: update multichain peer-dep and Solana APIs
Remove guidance to explicitly install @metamask/connect-multichain for single-ecosystem packages and simplify install commands across EVM and Solana quickstarts. Rename Solana methods and Wallet Standard features (solana_signMessage → signMessage, solana_signAndSendTransaction/signAndSendAllTransactions → signAndSendTransaction) and update batch guidance to use the variadic signAndSendTransaction call. Revise error handling docs to use the new multichain error classes (RPCInvokeMethodErr, RPCHttpErr, RPCReadonlyResponseErr, RPCReadonlyRequestErr) and expose wallet RPC codes on err.rpcCode; remove the internal transport 1013 note from provider docs. Misc: update Wagmi quickstart to require @metamask/connect-evm@^2.1.0 and adjust examples/usages across multichain, evm, solana, reference, and troubleshooting pages to match the new APIs and patterns.
* Standardize Wagmi capitalization in docs
Add a terminology rule for Wagmi and update docs for consistent capitalization. Changes touch the terminology rules and multiple MetaMask Connect docs (quickstarts, guides, troubleshooting, supported-platforms, and references) to use “Wagmi” consistently and include small copy/formatting fixes (polyfill guidance and minor punctuation/lineflow adjustments).
* Clarify Solana network support notes
Update Solana quickstart docs to clarify network support: state that Devnet and Testnet are supported only in the MetaMask browser extension and that on mobile (including QR flows) only Solana mainnet is supported. Remove the explicit reference and link to MetaMask Flask. Changes applied to nodejs.md and react-native.md.
* Vale fixes
Copy file name to clipboardExpand all lines: metamask-connect/evm/quickstart/react-native.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -142,6 +142,10 @@ if (typeof global.CustomEvent === 'undefined') {
142
142
}
143
143
```
144
144
145
+
:::note
146
+
The `Event` and `CustomEvent` polyfills above are only required if you also use Wagmi, which dispatches DOM events. The `@metamask/connect-*` packages use `eventemitter3` internally and don't need them.
147
+
:::
148
+
145
149
:::tip
146
150
For detailed troubleshooting of polyfill issues, see [React Native Metro polyfill issues](../../troubleshooting/metro-polyfill-issues.md).
Copy file name to clipboardExpand all lines: metamask-connect/evm/quickstart/wagmi.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,7 @@ Get started with MetaMask Connect EVM in a React and Wagmi dapp.
27
27
[Download the quickstart template](#set-up-using-a-template) or [manually set up MetaMask Connect EVM](#set-up-manually) in an existing dapp.
28
28
29
29
:::tip Migrating from `@metamask/sdk`?
30
-
If you are upgrading an existing wagmi project that used `@metamask/sdk`, see the
30
+
If you are upgrading an existing Wagmi project that used `@metamask/sdk`, see the
31
31
[Wagmi connector migration reference](#migrate-from-metamasksdk) at the bottom of this page
32
32
for a parameter mapping table.
33
33
:::
@@ -97,11 +97,11 @@ TOD0: Update with new screenshot and link
97
97
Install MetaMask Connect EVM along with its peer dependencies to an existing React project:
98
98
99
99
:::note Version requirements
100
-
This quickstart requires `wagmi@^3.6.0` and `wagmi/connectors@^8.0.0`
100
+
This quickstart requires `wagmi@^3.6.0`. The `metaMask` connector is imported from the `wagmi/connectors` subpath (part of the `wagmi` package) and requires `@metamask/connect-evm@^2.1.0`.
Copy file name to clipboardExpand all lines: metamask-connect/evm/reference/methods.md
+16Lines changed: 16 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -47,7 +47,11 @@ Creates a new EVM client instance.
47
47
|`ui.preferExtension`|`boolean`| No | Directly connects through the MetaMask extension when it's installed. The default is `true`. |
48
48
|`mobile.preferredOpenLink`|`(deeplink: string) => void`| No | A function that's called to open a deeplink to the MetaMask Mobile App. Required in React Native. |
49
49
|`mobile.useDeeplink`|`boolean`| No | Controls use of deeplinks for mobile connection flows. |
50
+
|`ui.showInstallModal`|`boolean`| No | Shows the MetaMask install modal when the extension isn't detected. |
50
51
|`eventHandlers`|`object`| No | Optional callbacks for connection lifecycle and [provider events](provider-api.md#events). |
52
+
|`debug`|`boolean`| No | Enables verbose SDK logging. The default is `false`. |
53
+
|`skipAutoAnnounce`|`boolean`| No | Opts out of automatic EIP-6963 provider announcement (default since `@metamask/connect-evm` 2.0.0). Call `client.announceProvider()` to announce manually. |
54
+
|`analytics.enabled`|`boolean`| No | Set to `false` to opt out of analytics. |
51
55
52
56
### Returns
53
57
@@ -274,6 +278,13 @@ Switches the active chain on the EVM client.
274
278
If the chain is not already added to the user's MetaMask wallet, the optional `chainConfiguration`
275
279
parameter triggers a `wallet_addEthereumChain` request as a fallback.
276
280
281
+
:::note
282
+
Since `@metamask/connect-evm` 1.2.0, calling `switchChain` without `chainConfiguration` for an
283
+
unrecognized chain rejects with the wallet's raw `4902` error (not a "No chain configuration found."
284
+
message). Handle `4902` in a `catch` block by retrying with `chainConfiguration` or calling
285
+
`wallet_addEthereumChain`.
286
+
:::
287
+
277
288
### Parameters
278
289
279
290
| Name | Type | Required | Description |
@@ -363,6 +374,11 @@ The EVM client exposes the following read-only properties:
363
374
|`selectedChainId`|`Hex \| undefined`| Currently selected chain ID as a hex string. |
364
375
|`status`|`ConnectEvmStatus`| Connection status: `'loaded'`, `'pending'`, `'connecting'`, `'connected'`, or `'disconnected'`. |
365
376
377
+
:::note
378
+
On the EVM client, `status` is a `ConnectEvmStatus`. Since `@metamask/connect-evm` 0.11.0 it
379
+
reflects the EVM client's own status and no longer proxies `MultichainClient.status`.
Copy file name to clipboardExpand all lines: metamask-connect/evm/reference/provider-api.md
+15Lines changed: 15 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,6 +36,10 @@ Throughout this documentation, we refer to the selected provider using `provider
36
36
When using MetaMask Connect EVM, you get the same EIP-1193 provider via `client.getProvider`.
37
37
The provider returned by MetaMask Connect EVM is available immediately after `createEVMClient` resolves
38
38
and supports the same methods, properties, and events documented below.
39
+
40
+
Since `@metamask/connect-evm` 2.0.0, MetaMask Connect EVM announces its provider through EIP-6963 by
41
+
default when the native MetaMask extension hasn't already announced one. Pass `skipAutoAnnounce: true`
42
+
to `createEVMClient` to opt out, and call `client.announceProvider` to announce manually.
39
43
:::
40
44
41
45
## Properties
@@ -203,6 +207,7 @@ provider // Or window.ethereum if you don't support EIP-6963.
203
207
```
204
208
205
209
The provider emits this event when the currently connected chain changes.
210
+
The `chainId` is a hex string (for example, `0x1`), not a decimal number.
206
211
Listen to this event to [detect a user's network](../guides/manage-networks.md).
207
212
208
213
### `connect`
@@ -329,6 +334,8 @@ You can use the error `code` property to determine why the request failed.
329
334
Common codes and their meaning include:
330
335
331
336
-`4001` - The request is rejected by the user.
337
+
-`-32002` - A request is already pending. Don't send another request; wait for the user to respond in MetaMask.
338
+
-`4902` - The chain isn't recognized by the wallet. Add it with `wallet_addEthereumChain`, or pass `chainConfiguration` to [`switchChain`](methods.md#switchchain).
332
339
-`-32602` - The parameters are invalid.
333
340
-`-32603` - Internal error.
334
341
@@ -340,6 +347,14 @@ The [`eth-rpc-errors`](https://npmjs.com/package/eth-rpc-errors) package impleme
340
347
returned by the MetaMask provider, and can help you identify their meaning.
341
348
:::
342
349
350
+
:::note Typed errors
351
+
When you use the multichain client, the core (`@metamask/connect-multichain`) exports typed error
352
+
classes for `instanceof` checks: `RPCInvokeMethodErr` (wraps wallet `invokeMethod` errors; read the
353
+
wallet's original code from `err.rpcCode`), `RPCHttpErr`, `RPCReadonlyResponseErr`, and
354
+
`RPCReadonlyRequestErr`. The EVM provider itself rejects with a standard EIP-1193 `ProviderRpcError`
355
+
(use `err.code`).
356
+
:::
357
+
343
358
## Next steps
344
359
345
360
-[JSON-RPC API reference](./json-rpc-api/index.md)
0 commit comments