For AI agents: a documentation index is available at /llms.txt. A markdown version of this page is available at the same URL with .md appended (or via Accept: text/markdown).
Skip to main content

MetaMask Connect Solana methods

MetaMask Connect Solana (@metamask/connect-solana) exposes several methods, including:

The client wraps @metamask/connect-multichain and handles wallet discovery and session management automatically.

createSolanaClient​

Creates a new Solana client instance. By default, the wallet is automatically registered with the Wallet Standard registry on creation, making MetaMask discoverable by Solana dapps and wallet adapters.

Under the hood, createSolanaClient delegates to createMultichainClient, which is a singleton. Calling createSolanaClient multiple times returns the same underlying multichain core and session.

Parameters​

See SolanaConnectOptions.

Returns​

A promise that resolves to a SolanaClient instance. The client is a singleton; calling createSolanaClient again returns the same instance.

Example​

import { createSolanaClient, getInfuraRpcUrls } from '@metamask/connect-solana'

const client = await createSolanaClient({
dapp: {
name: 'My Solana Dapp',
url: 'https://mydapp.com',
},
api: {
supportedNetworks: getInfuraRpcUrls({
infuraApiKey: 'YOUR_INFURA_API_KEY',
networks: ['mainnet', 'devnet'],
}),
},
})

getInfuraRpcUrls​

Generates Solana Infura RPC URLs keyed by network name. The returned map can be passed directly to createSolanaClient({ api: { supportedNetworks } }).

Under the hood, this delegates to the multichain getInfuraRpcUrls, which maps CAIP-2 chain IDs to Infura endpoints, then translates the result back to Solana network names.

note

Each chain must be activated in your Infura dashboard before getInfuraRpcUrls can generate working URLs for it.

Parameters​

NameTypeRequiredDescription
infuraApiKeystringYesYour Infura API key.
networksSolanaNetwork[]YesSolana networks to include (for example, ['mainnet', 'devnet']).

Returns​

SolanaSupportedNetworks, a map of network names to Infura RPC URLs.

Example​

import { createSolanaClient, getInfuraRpcUrls } from '@metamask/connect-solana'

// Each chain must be active in your Infura dashboard
const supportedNetworks = getInfuraRpcUrls({
infuraApiKey: 'YOUR_INFURA_API_KEY',
networks: ['mainnet', 'devnet'],
})
// {
// mainnet: 'https://solana-mainnet.infura.io/v3/YOUR_INFURA_API_KEY',
// devnet: 'https://solana-devnet.infura.io/v3/YOUR_INFURA_API_KEY',
// }

const client = await createSolanaClient({
dapp: { name: 'My Solana Dapp', url: 'https://mydapp.com' },
api: { supportedNetworks },
})

getWallet​

Returns a Wallet Standard compatible MetaMask wallet instance. Use this to access wallet features directly outside of the Solana Wallet Adapter.

Returns​

A Wallet Standard Wallet object.

Example​

const wallet = client.getWallet()
console.log('Wallet name:', wallet.name)

registerWallet​

Registers the MetaMask wallet with the Wallet Standard registry, making it automatically discoverable by Solana dapps. This is a no-op if the wallet was already auto-registered during creation (that is, skipAutoRegister was not set to true).

Returns​

A promise that resolves when registration is complete.

Example​

const client = await createSolanaClient({
dapp: { name: 'My Solana Dapp', url: 'https://mydapp.com' },
skipAutoRegister: true,
})

// Register manually when ready
await client.registerWallet()

disconnect​

Disconnects all Solana scopes from MetaMask. This only revokes the Solana-specific scopes:

  • solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp (mainnet)
  • solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1 (devnet)
  • solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z (testnet)

It does not terminate the broader multichain session if non-Solana scopes (such as EVM) are also active.

Returns​

A promise that resolves when the disconnect is complete.

Example​

await client.disconnect()

Properties​

PropertyTypeDescription
coreMultichainCoreThe underlying MultichainCore instance.

The core property exposes the full multichain client, giving access to lower-level methods such as connect, getSession, invokeMethod, on, and off.

Example​

const session = await client.core.getSession()
const solAccounts = session.sessionScopes['solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp']?.accounts || []
console.log('Solana accounts:', solAccounts)

Supported Wallet Standard features​

The wallet returned by getWallet implements the following Wallet Standard features. Access them via wallet.features['<feature>'].

FeatureDescription
standard:connectConnect to the wallet and receive the user's accounts.
standard:disconnectDisconnect from the wallet.
standard:eventsSubscribe to account and chain change events.
solana:signMessageSign an arbitrary message (returns a signature).
solana:signTransactionSign one or more transactions without broadcasting them.
solana:signAndSendTransactionSign one or more transactions and broadcast them to the network. Pass multiple inputs to send a batch.

Example​

const wallet = client.getWallet()

const { accounts } = await wallet.features['standard:connect'].connect()

const message = new TextEncoder().encode('Hello Solana')
const [{ signature }] = await wallet.features['solana:signMessage'].signMessage({
account: accounts[0],
message,
})

Types​

SolanaNetwork​

type SolanaNetwork = 'mainnet' | 'devnet' | 'testnet'

SolanaSupportedNetworks​

A partial record mapping SolanaNetwork names to RPC URL strings.

type SolanaSupportedNetworks = Partial<Record<SolanaNetwork, string>>

SolanaConnectOptions​

Configuration options passed to createSolanaClient.

FieldTypeRequiredDescription
dappobjectYesDapp identification and branding settings.
dapp.namestringYesName of your dapp.
dapp.urlstringNoURL of your dapp.
dapp.iconUrlstringNoURL of your dapp icon.
apiobjectNoOptional API configuration.
api.supportedNetworksSolanaSupportedNetworksNoMap of network names (mainnet, devnet, testnet) to RPC URLs.
analytics.integrationTypestringNoIdentifies your integration in analytics events.
debugbooleanNoReserved for future use; not currently forwarded to the underlying client.
skipAutoRegisterbooleanNoSkips auto-registering the wallet during creation. The default is false.
note

createSolanaClient does not accept eventHandlers. To listen for lower-level multichain events (such as session changes), use client.core.on after creating the client. See the multichain event methods.

SolanaClient​

The object returned by createSolanaClient.

Property / MethodTypeDescription
coreMultichainCoreThe underlying MultichainCore instance.
getWallet() => WalletReturns a Wallet Standard compatible MetaMask wallet instance.
registerWallet() => Promise<void>Registers MetaMask with the Wallet Standard registry.
disconnect() => Promise<void>Disconnects all Solana scopes from MetaMask.

Next steps​