Skip to main content

MetaMask Connect Solana SDK methods

MetaMask Connect Solana (@metamask/connect-solana) provides a wallet-standard integration for connecting to MetaMask as a Solana wallet. It 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.

Parameters

NameTypeRequiredDescription
dapp.namestringYesName of your dApp.
dapp.urlstringNoURL of your dApp.
dapp.iconUrlstringNoIcon URL for your dApp.
api.supportedNetworksSolanaSupportedNetworksNoMap of network names (mainnet, devnet, testnet) to RPC URLs.
debugbooleanNoReserved for future use; not currently forwarded to the underlying client.
skipAutoRegisterbooleanNoSkip auto-registering the wallet during creation (defaults to false).

Returns

A promise that resolves to a SolanaClient instance.

Example

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

const client = await createSolanaClient({
dapp: {
name: 'My Solana DApp',
url: 'https://mydapp.com',
},
api: {
supportedNetworks: {
mainnet: 'https://api.mainnet-beta.solana.com',
devnet: 'https://api.devnet.solana.com',
},
},
})

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, solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1, solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z); 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)

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.iconUrlstringNoIcon URL for your dApp.
apiobjectNoOptional API configuration.
api.supportedNetworksSolanaSupportedNetworksNoMap of network names (mainnet, devnet, testnet) to RPC URLs.
debugbooleanNoReserved for future use; not currently forwarded to the underlying client.
skipAutoRegisterbooleanNoSkip auto-registering the wallet during creation (defaults to false).

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.