> **Can't find what you're looking for?** Use `search_docs` on the docs MCP server at `https://www.openfort.io/api/mcp` to find what you need.
>
> **Have feedback?** Use `submit_feedback` on the same MCP server.

# Active wallet (Solana)

The active wallet is the wallet currently used for signing and sending transactions. Use [`useSolanaEmbeddedWallet`](https://www.openfort.io/docs/products/embedded-wallet/react/hooks/useSolanaEmbeddedWallet) to read and manage the active Solana wallet. For Ethereum, see [Active wallet (Ethereum)](https://www.openfort.io/docs/products/embedded-wallet/react/wallet/active-wallet/ethereum).

## View active wallet

Use `useSolanaEmbeddedWallet` to read the active wallet:

```tsx
import { useSolanaEmbeddedWallet } from "@openfort/react/solana"

function ActiveWalletDisplay() {
  const { activeWallet, cluster, status } = useSolanaEmbeddedWallet()

  if (status !== "connected" || !activeWallet) return <div>Not connected</div>

  return (
    <div>
      <p>Address: {activeWallet.address}</p>
      <p>Cluster: {cluster}</p>
    </div>
  )
}
```

## List user wallets

The hook returns a list of [`ConnectedEmbeddedSolanaWallet`](#connectedembeddedsolanawallet) objects.

```tsx
import { useSolanaEmbeddedWallet } from "@openfort/react/solana"

function WalletList() {
  const { wallets, activeWallet } = useSolanaEmbeddedWallet()

  return (
    <ul>
      {wallets.map((w) => (
        <li key={w.id}>
          {w.address} {w.id === activeWallet?.id && "(active)"}
        </li>
      ))}
    </ul>
  )
}
```

## Change active wallet

To change the active wallet, use the `setActive` method from the `useSolanaEmbeddedWallet` hook. In this example, we change the active wallet by providing the `address`.

```tsx
import { useSolanaEmbeddedWallet } from "@openfort/react/solana"

function SwitchWallet() {
  const {
    isConnecting,
    setActive,
  } = useSolanaEmbeddedWallet()

  const handleChangeWallet = async (address: string) => {
    const result = await setActive({ address })
    if (result.error) return console.error(result.error.shortMessage)
    if (result.needsRecovery) console.log("Recovery required")
  }

  return (
    <button onClick={() => handleChangeWallet("BASE58_ADDRESS")} disabled={isConnecting}>
      Switch wallet
    </button>
  )
}
```

You can also pass `recoveryParams`, `recoveryMethod`, `passkeyId`, `password`, or `otpCode` when recovering a wallet. The result reports `needsRecovery: true` when recovery is still required.

## ConnectedEmbeddedSolanaWallet

* Wallet address (base58) and ID
* Recovery method used for wallet restoration
* `getProvider()` for Solana signing

**Properties:**

* `address`: The wallet address (base58).
* `id`: Wallet identifier.
* `chainType`: Always `'SVM'`.
* `walletIndex`: Index among the user's Solana wallets.
* `recoveryMethod`: The recovery method (e.g. AUTOMATIC, PASSWORD, PASSKEY).
* `getProvider()`: Returns the Solana signing provider.

### Example usage

```tsx
import { useSolanaEmbeddedWallet } from "@openfort/react/solana"

function MyComponent() {
  const { activeWallet, wallets } = useSolanaEmbeddedWallet()

  return (
    <div>
      <h1>Solana wallet</h1>
      <p>Address: {activeWallet?.address}</p>
      <h2>All wallets</h2>
      <ul>
        {wallets.map((wallet) => (
          <li key={wallet.address}>
            {wallet.address} — {wallet.id === activeWallet?.id ? "Active" : "Inactive"}
          </li>
        ))}
      </ul>
    </div>
  )
}
```
