Skip to main content

Checking if a wallet is a Solana wallet

React Native
    import { isSolanaWallet } from '@dynamic-labs/solana';
    import { dynamicClient } from '<path to client file>';

    const wallet = dynamicClient.wallets.primary;
    if (!wallet || !isSolanaWallet(wallet)) {
      throw new Error('This wallet is not a Solana wallet');
    }

    const connection = dynamicClient.solana.getConnection();

Get Connection

import { createClient } from '@dynamic-labs/client'
import { SolanaExtension } from '@dynamic-labs/solana-extension'

export const dynamicClient = createClient({
  environmentId: 'YOUR-ENVIRONMENT-ID',
}).extend(SolanaExtension())

Get Signer

import { createClient } from '@dynamic-labs/client'
import { SolanaExtension } from '@dynamic-labs/solana-extension'

export const dynamicClient = createClient({
  environmentId: 'YOUR-ENVIRONMENT-ID',
}).extend(SolanaExtension())

Custom Connection (React only)

In some cases you would want to override the default settings of the Web3.js Connection. React provides the SolanaWalletConnectorsWithConfig to customize Web3.js Connection configuration with commitment levels, HTTP headers, and custom RPC URLs.
React
import { DynamicContextProvider } from '@dynamic-labs/sdk-react-core';
import { SolanaWalletConnectorsWithConfig } from '@dynamic-labs/solana';

<DynamicContextProvider
  settings={{
    walletConnectors: [
      SolanaWalletConnectorsWithConfig({
        commitment: "confirmed",
        httpHeaders: {
          "X-Requested-With": "XMLHttpRequest",
        },
        customRpcUrls: {
          solana: ["http://YOUR_URL"],
          eclipse: ["http://YOUR_URL"],
        },
      }),
    ],
    ... // other settings
  }}
>
  {...}
</DynamicContextProvider>

Examples

You can find examples of how to interact with Solana wallets in the examples section: