Check If User's SC Wallet is Deployed or Not

import { useEffect, useState } from "react";
import { useBundler } from "./useBundler";

export const useIsWalletDeployed = () => {
  const [isUserWalletNotDeployed, setIsUserWalletNotDeployed] = useState<boolean>(false);

  const { walletAPI } = useBundler();

  useEffect(() => {
    (async () => {
      if (walletAPI) {
        const isNotDeployed = await walletAPI.checkAccountPhantom();
        if (isNotDeployed) {
          setIsUserWalletNotDeployed(true);
        }
      }
    })();
  }, [walletAPI]);

  return isUserWalletNotDeployed;
};

Last updated