Skip to main content

Connect to EVM and Solana in MetaMask

Get started with MetaMask Connect in your multichain JavaScript dapp. You can connect to EVM networks and Solana in MetaMask at the same time, and make requests to each network without having to switch between them.

Prerequisites

  • Node.js version 19 or later installed.
  • A package manager installed, such as npm, Yarn, pnpm, or bun.
  • MetaMask installed in your browser or on mobile.

Steps

1. Install MetaMask Connect

Install MetaMask Connect in an existing JavaScript project:

npm install @metamask/connect/multichain

2. Initialize MetaMask Connect

Initialize MetaMask Connect with configuration options:

import { createMultichainClient } from "@metamask/connect/multichain"

const multichainClient = createMultichainClient({
dappMetadata: {
name: "Example multichain dapp",
url: window.location.href,
iconUrl: "https://mydapp.com/icon.png" // Optional
},
infuraAPIKey: process.env.INFURA_API_KEY,
})

This example configures MetaMask Connect with the following options:

  • dappMetadata - Ensures trust by showing your dapp's name, url, and iconUrl during connection.
  • infuraAPIKey - Enables read-only RPC and load‑balancing. Set this option to your Infura API key.

3. Connect and use provider

Connect to MetaMask and get the provider for RPC requests:

const provider = multichainClient.getProvider()

await provider.request({
chain: 'eip155:1',
method: 'eth_sendTransaction',
params: [...]
});

Next steps

Now that you've connected to multiple ecosystems in MetaMask, learn how to send EVM and Solana transactions.