Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
0b79037
SDK new structure PoC
alexandratran Sep 23, 2025
44a6248
edits
alexandratran Sep 24, 2025
f234baf
remove custom reference component
alexandratran Sep 24, 2025
f331654
edits
alexandratran Sep 25, 2025
e2f4b8b
Merge branch 'main' into sdk-new-structure
alexandratran Sep 30, 2025
ef20ee1
fix links, update redirects, "metamask wallet sdk"
alexandratran Sep 30, 2025
39b9b16
Merge branch 'main' into sdk-new-structure
alexandratran Oct 16, 2025
905d9a8
add simplified api reference with two examples
alexandratran Oct 18, 2025
549887c
missing files
alexandratran Oct 18, 2025
1b97b2c
Merge branch 'main' into sdk-new-structure
alexandratran Oct 20, 2025
bb103fb
remove starknet docs
alexandratran Oct 21, 2025
8216d8b
copy over solana docs
alexandratran Oct 21, 2025
34aed2c
Merge branch 'main' into sdk-new-structure
alexandratran Oct 22, 2025
d64e8a4
Merge branch 'main' into sdk-new-structure
alexandratran Oct 23, 2025
e02092a
Update terminology and restructure EVM docs
alexandratran Oct 23, 2025
956c09a
fix broken links
alexandratran Oct 23, 2025
86d2dfc
Merge branch 'main' into sdk-new-structure
alexandratran Nov 4, 2025
f70f940
fix broken links
alexandratran Nov 4, 2025
e1e0008
Add/update Solana Wallet Adapter docs (#2443)
alexandratran Nov 7, 2025
37a4d06
Merge branch 'main' into sdk-new-structure
alexandratran Nov 10, 2025
30d0439
Update mobile products menu
alexandratran Nov 10, 2025
3db005f
Update MM Connect EVM JS code samples with potential new usage (#2454)
alexandratran Nov 12, 2025
d122361
Merge branch 'main' into sdk-new-structure
alexandratran Nov 13, 2025
360383d
Remove ParserOpenRPC component and replace usage in Linea services
alexandratran Nov 14, 2025
98476fe
Merge branch 'main' into sdk-new-structure
alexandratran Nov 18, 2025
c04fb6d
fix broken link
alexandratran Nov 18, 2025
b034e01
Add more multichain info (#2479)
alexandratran Nov 18, 2025
77bb9a9
Merge branch 'main' into sdk-new-structure
alexandratran Nov 27, 2025
b4716d6
Enhance JS section {WIP} (#2450)
shahbaz17 Nov 27, 2025
2a6e4ab
Add view & wagmi options
shahbaz17 Nov 27, 2025
6cf2880
Merge branch 'main' into sdk-new-structure
alexandratran Nov 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
Prev Previous commit
Next Next commit
Update MM Connect EVM JS code samples with potential new usage (#2454)
* Update MM Connect EVM JS code samples with potential new usage

* remove initialize sdk comment

* add provider to code snippets

* fix cursor bugs

* remove /evm from wagmi install
  • Loading branch information
alexandratran authored Nov 12, 2025
commit 3db005f24e8a3f09dae13b7d8c8f580acd903d8a
2 changes: 1 addition & 1 deletion sdk/evm/connect/guides/connectkit.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ You can [download the quickstart template](#set-up-using-a-template) or [manuall

## Set up manually

### 1. Install the SDK
### 1. Install MM Connect

Install MM Connect along with its peer dependencies to an existing React project:

Expand Down
2 changes: 1 addition & 1 deletion sdk/evm/connect/guides/dynamic.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ See how to [use the combined SDKs](#usage).

### 1. Install dependencies

Install the SDK and the required dependencies to an existing project:
Install MM Connect and the required dependencies to an existing project:

```bash npm2yarn
npm install @dynamic-labs/sdk-react-core @dynamic-labs/ethereum @dynamic-labs/wagmi-connector wagmi viem @tanstack/react-query
Expand Down
6 changes: 3 additions & 3 deletions sdk/evm/connect/guides/javascript/batch-requests.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ When using `metamask_batch`, keep in mind the following:
The following is an example of batching JSON-RPC requests using `metamask_batch`:

```js
import { MetaMaskSDK } from "@metamask/sdk";
import { createEVMClient } from "@metamask/connect/evm";

const MMSDK = new MetaMaskSDK();
const provider = MMSDK.getProvider();
const evmClient = createEVMClient();
const provider = evmClient.getProvider();

async function handleBatchRequests() {
// Example batch: one personal_sign call and one eth_sendTransaction call.
Expand Down
69 changes: 38 additions & 31 deletions sdk/evm/connect/guides/javascript/display-tokens.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,30 +38,34 @@ extension (not on mobile).
To prompt users to add an ERC-20 token, you can add something like the following to your project script:

```javascript
import { createEVMClient } from "@metamask/connect/evm";

const evmClient = createEVMClient();
const provider = evmClient.getProvider();

const tokenAddress = "0xd00981105e61274c8a5cd5a88fe7e037d935b513"
const tokenSymbol = "TUT"
const tokenDecimals = 18
const tokenImage = "http://placekitten.com/200/300"

try {
// 'wasAdded' is a boolean. Like any RPC method, an error can be thrown.
const wasAdded = await provider // Or window.ethereum if you don't support EIP-6963.
.request({
method: "wallet_watchAsset",
params: {
type: "ERC20",
options: {
// The address of the token.
address: tokenAddress,
// A ticker symbol or shorthand, up to 5 characters.
symbol: tokenSymbol,
// The number of decimals in the token.
decimals: tokenDecimals,
// A string URL of the token logo.
image: tokenImage,
},
const wasAdded = await provider.request({
method: "wallet_watchAsset",
params: {
type: "ERC20",
options: {
// The address of the token.
address: tokenAddress,
// A ticker symbol or shorthand, up to 5 characters.
symbol: tokenSymbol,
// The number of decimals in the token.
decimals: tokenDecimals,
// A string URL of the token logo.
image: tokenImage,
},
})
},
})

if (wasAdded) {
console.log("Thanks for your interest!")
Expand Down Expand Up @@ -110,21 +114,25 @@ To prompt users to add a single NFT, add something like the following to your pr
`wallet_watchAsset` supports both ERC-721 and ERC-1155 NFT standards.

```javascript
import { createEVMClient } from "@metamask/connect/evm";

const evmClient = createEVMClient();
const provider = evmClient.getProvider();

try {
// wasAdded is a boolean. Like any RPC method, an error can be thrown.
const wasAdded = await provider // Or window.ethereum if you don't support EIP-6963.
.request({
method: "wallet_watchAsset",
params: {
type: "ERC721", // Or "ERC1155".
options: {
// The address of the token.
address: "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
// ERC-721 or ERC-1155 token ID.
tokenId: "1",
},
const wasAdded = await provider.request({
method: "wallet_watchAsset",
params: {
type: "ERC721", // Or "ERC1155".
options: {
// The address of the token.
address: "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
// ERC-721 or ERC-1155 token ID.
tokenId: "1",
},
})
},
})

if (wasAdded) {
console.log("User successfully added the token!")
Expand All @@ -143,8 +151,7 @@ To prompt users to add multiple NFTs, use `sendAsync()` instead of
For example:

```javascript
provider // Or window.ethereum if you don't support EIP-6963.
.sendAsync([{
provider.sendAsync([{
method: "wallet_watchAsset",
params: {
type: "ERC721",
Expand All @@ -164,5 +171,5 @@ provider // Or window.ethereum if you don't support EIP-6963.
},
},
...
])
])
```
28 changes: 14 additions & 14 deletions sdk/evm/connect/guides/javascript/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,25 +84,25 @@ You've successfully set up MM Connect.

## Set up manually

### 1. Install the SDK
### 1. Install MM Connect

Install the SDK in an existing JavaScript project:
Install MM Connect in an existing JavaScript project:

```bash npm2yarn
npm install @metamask/sdk
npm install @metamask/connect/evm
```

### 2. Initialize the SDK
### 2. Initialize MM Connect

The following are examples of using the SDK in various JavaScript environments:
The following are examples of using MM Connect in various JavaScript environments:

<Tabs>
<TabItem value="Web dapps">

```javascript
import { MetaMaskSDK } from "@metamask/sdk"
import { createEVMClient } from "@metamask/connect/evm"

const MMSDK = new MetaMaskSDK({
const evmClient = createEVMClient({
dappMetadata: {
name: "Example JavaScript dapp",
url: window.location.href,
Expand All @@ -119,7 +119,7 @@ const MMSDK = new MetaMaskSDK({
<head>
<script src="https://c0f4f41c-2f55-4863-921b-sdk-docs.github.io/cdn/metamask-sdk.js"></script>
<script>
const MMSDK = new MetaMaskSDK.MetaMaskSDK({
const evmClient = createEVMClient({
dappMetadata: {
name: "Example JavaScript dapp",
url: window.location.href,
Expand All @@ -145,9 +145,9 @@ These examples configure the SDK with the following options:
Connect to MetaMask and get the provider for RPC requests:

```javascript
const provider = MMSDK.getProvider()
const provider = evmClient.getProvider()

const accounts = await MMSDK.connect()
const accounts = await evmClient.connect()
console.log("Connected account:", accounts[0])

const result = await provider.request({
Expand All @@ -157,7 +157,7 @@ const result = await provider.request({
console.log("eth_accounts result:", result)
```

`MMSDK.connect()` handles cross-platform connection (desktop and mobile), including deeplinking.
`evmClient.connect()` handles cross-platform connection (desktop and mobile), including deeplinking.

Use `provider.request()` for arbitrary [JSON-RPC requests](../../reference/json-rpc-api/index.md) like `eth_chainId` or `eth_getBalance`, or for [batching requests](batch-requests.md) via `metamask_batch`.

Expand All @@ -175,15 +175,15 @@ Use `provider.request()` for arbitrary [JSON-RPC requests](../../reference/json-

```javascript
// 1. Connect and get accounts
const accounts = await MMSDK.connect()
const accounts = await evmClient.connect()

// 2. Connect and sign in one step
const signResult = await MMSDK.connectAndSign({
const signResult = await evmClient.connectAndSign({
msg: "Sign in to the dapp",
})

// 3. Get provider for RPC requests
const provider = MMSDK.getProvider()
const provider = evmClient.getProvider()

// 4. Make an RPC request
const result = await provider.request({
Expand Down
13 changes: 9 additions & 4 deletions sdk/evm/connect/guides/javascript/interact-with-contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,19 @@ You can implement smart contract interactions directly in JavaScript.
The following example reads contract data using the [`eth_call`](../../reference/json-rpc-api/index.md) RPC method:

```javascript
import { createEVMClient } from "@metamask/connect/evm";

const evmClient = createEVMClient();
const provider = evmClient.getProvider();

async function getBalance(contractAddress, userAddress) {
try {
// Create function signature for balanceOf(address)
const functionSignature = "0x70a08231";
// Pad address to 32 bytes
const encodedAddress = userAddress.slice(2).padStart(64, "0");

const result = await ethereum.request({
const result = await provider.request({
method: "eth_call",
params: [{
to: contractAddress,
Expand Down Expand Up @@ -69,7 +74,7 @@ RPC methods:
async function mintNFT(contractAddress, tokenId) {
try {
// Get user's account
const accounts = await ethereum.request({
const accounts = await provider.request({
method: "eth_requestAccounts"
});

Expand All @@ -79,7 +84,7 @@ async function mintNFT(contractAddress, tokenId) {
const encodedTokenId = tokenId.toString(16).padStart(64, "0");

// Send transaction
const txHash = await ethereum.request({
const txHash = await provider.request({
method: "eth_sendTransaction",
params: [{
from: accounts[0],
Expand All @@ -102,7 +107,7 @@ async function watchTransaction(txHash) {
return new Promise((resolve, reject) => {
const checkTransaction = async () => {
try {
const tx = await ethereum.request({
const tx = await provider.request({
method: "eth_getTransactionReceipt",
params: [txHash],
});
Expand Down
13 changes: 9 additions & 4 deletions sdk/evm/connect/guides/javascript/manage-networks.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,15 @@ The following example detects the current network using the
[`chainChanged`](../../reference/provider-api.md#chainchanged) provider event:

```javascript
import { createEVMClient } from "@metamask/connect/evm";

const evmClient = createEVMClient();
const provider = evmClient.getProvider();

// Get current chain ID
async function getCurrentChain() {
try {
const chainId = await ethereum.request({
const chainId = await provider.request({
method: "eth_chainId"
});
console.log("Current chain ID:", chainId);
Expand All @@ -43,7 +48,7 @@ async function getCurrentChain() {
}

// Listen for network changes
ethereum.on("chainChanged", (chainId) => {
provider.on("chainChanged", (chainId) => {
console.log("Network changed to:", chainId);
// We recommend reloading the page
window.location.reload();
Expand Down Expand Up @@ -80,15 +85,15 @@ async function switchNetwork(networkKey) {

try {
// Try to switch to the network
await ethereum.request({
await provider.request({
method: "wallet_switchEthereumChain",
params: [{ chainId: network.chainId }]
});
} catch (err) {
// If the error code is 4902, the network needs to be added
if (err.code === 4902) {
try {
await ethereum.request({
await provider.request({
method: "wallet_addEthereumChain",
params: [{
chainId: network.chainId,
Expand Down
16 changes: 7 additions & 9 deletions sdk/evm/connect/guides/javascript/manage-user-accounts.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@ and [`accountsChanged`](../../reference/provider-api.md#accountschanged) provide
For example:

```javascript
import { MetaMaskSDK } from "@metamask/sdk";
import { createEVMClient } from "@metamask/connect/evm";

// Initialize SDK
const MMSDK = new MetaMaskSDK();
const provider = MMSDK.getProvider();
const evmClient = createEVMClient();
const provider = evmClient.getProvider();

// Connect wallet
async function connectWallet() {
Expand Down Expand Up @@ -68,7 +67,7 @@ async function connectWallet() {
// Disconnect wallet
async function disconnectWallet() {
try {
await MMSDK.terminate()
await evmClient.terminate()
} catch (err) {
console.error("Error with disconnecting:", err)
}
Expand Down Expand Up @@ -106,14 +105,13 @@ You can use MM Connect's [`connectAndSign`](../../reference/methods.md#connectan
For example:

```js
import { MetaMaskSDK } from "@metamask/sdk"
import { createEVMClient } from "@metamask/connect/evm";

const MMSDK = new MetaMaskSDK()
const provider = MMSDK.getProvider()
const evmClient = createEVMClient();

async function handleConnectAndSign() {
try {
const signature = await MMSDK.connectAndSign({ msg: "Hello in one go!" })
const signature = await evmClient.connectAndSign({ msg: "Hello in one go!" })
console.log("Signature:", signature)
} catch (err) {
console.error("Error with connectAndSign:", err)
Expand Down
Loading