# Active wallet (Solana)

The active wallet is the wallet currently used for signing and sending transactions. Use [`useSolanaEmbeddedWallet`](/docs/products/embedded-wallet/react/hooks/useSolanaEmbeddedWallet) to read and manage the active Solana wallet. For Ethereum, see [Active wallet (Ethereum)](/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) => {
    await setActive({ address })
  }

  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.

## 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>
  )
}
```
