Skip to content

useWalletAuth

Manages wallet connection and linking with SIWE (Sign-In With Ethereum).

Use cases:
  • Connect wallets and authenticate users via SIWE.
  • Link wallets to a user account.
Returns:
  • connectWallet, linkWallet: Connect or link wallet functions.
  • Status flags: isLoading, isError, isSuccess.
import { useWalletAuth } from "@openfort/react-native"
 
function SampleComponent() {
  const {
    generateSiweMessage, 
    signInWithSiwe,
    linkSiwe,
    isLoading, // Indicates if the hook is currently loading.
    isError, // Indicates if the hook has encountered an error.
    isSuccess, // Indicates if the hook has successfully completed.
    error, // The error object if an error occurred, otherwise null.
    isAwaitingSignature, // Indicates if the hook is awaiting a signature.
    isGeneratingMessage, // Indicates if the hook is generating a SIWE message.
    isSubmittingSignature, // Indicates if the hook is submitting a signature.
  } = useWalletAuth({
    throwOnError, // Whether to throw errors.
    onSuccess, // Callback function to execute on success.
    onError, // Callback function to execute on error.
    onSettled, // Callback function to execute when the operation is settled (either success or error).
  })
  // ...
}