> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dynamic.xyz/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Checking Wallet Account Availability

To be able to do any signing actions with your wallet account, it must be available for use in your wallet app.

Some wallets allow you to sign without the need for that wallet account to be the currently selected one in the wallet app, but others do not.

You can preemptively check if the wallet account is available for signing by calling the `assertWalletAccountSigningAvailability` function, which will throw a `WalletAccountNotSelectedError` error
in case the wallets app required the wallet account to be the currently selected one and the wallet account you trying to sign the message with is not the currently selected one.

We'll do the same check once a sign function is called, but you can check it beforehand to avoid errors.

## Usage

```javascript theme={"system"}
import {
    assertWalletAccountSigningAvailability,
    type WalletProviderMethodUnavailableError
} from '@dynamic-labs-sdk/client';

const doSomeSignAction = async () => {
    try {
        await assertWalletAccountSigningAvailability({ walletAccount });
    } catch (error instanceof WalletAccountNotSelectedError) {
        console.error(error);
        // Prompt user to reconnect and/or make the required wallet account active in their wallet app
        return;
    }

    // Do some sign action
    // ...
}

```

## React

```tsx theme={"system"}
import {
  assertWalletAccountSigningAvailability,
  signMessage,
} from '@dynamic-labs-sdk/client';
import { useGetWalletAccounts } from '@dynamic-labs-sdk/react-hooks';
import { useState } from 'react';

function SignButton({ message }) {
  const { data: walletAccounts = [] } = useGetWalletAccounts();
  const walletAccount = walletAccounts[0];
  const [error, setError] = useState('');

  const handleSign = async () => {
    if (!walletAccount) return;
    setError('');
    try {
      await assertWalletAccountSigningAvailability({ walletAccount });
      await signMessage({ walletAccount, message });
    } catch (err) {
      setError('Please make sure the correct account is active in your wallet app.');
    }
  };

  return (
    <div>
      <button onClick={handleSign} disabled={!walletAccount}>Sign</button>
      {error && <p style={{ color: 'red' }}>{error}</p>}
    </div>
  );
}
```

## Error Handling

If the wallet account you're checking is not connected and active in the wallet app, the function will throw a `WalletAccountNotSelectedError` error.

The error contains an `expectedAddress`, which is the address that you are trying to sign the message with, and a `selectedAddress`, which is the address that is currently active in the wallet app.
If there is no `selectedAddress` prop, it probably means that there is no connected wallet accounts to your app.

## Related functions

* [Getting the Wallet Account Given an Address and Chain](/javascript/reference/wallets/get-wallet-account-from-address)
* [Signing a Message](/javascript/reference/wallets/sign-message)
* [Getting Connected Addresses](/javascript/reference/wallets/get-connected-addresses)
* [Wallet Provider Events](/javascript/reference/wallets/wallet-provider-events)
