Enable wallet authentication in the Privy
Dashboard before implementing this feature.
- React
- React Native
- Swift
- Android
- Flutter
To authenticate a user via an Ethereum wallet (SIWE) without Privy UIs, use the React SDK’s
Then, when you attempt to login with a Phantom Solana wallet, you will be prompted to indicate whether you are signing with a Ledger wallet,
which will initiate a separate SIWS flow wherein which a no-op transaction will be signed and used for verification.
useLoginWithSiwe hook.In order to use Privy’s login with wallet flow, users must actively have a wallet
connected to your app from which you can request signatures.
Generate SIWE message
Parameters
EIP-55 checksum-encoded wallet address performing the signing.
EIP-155 Chain ID to which the session is bound (in CAIP-2 format), e.g.
eip155:1.Whether to disable signup for this login flow.
Returns
A SIWE message that can be signed by the wallet.
Sign the SIWE message
Request an EIP-191personal_sign signature for the message returned by generateSiweMessage from the connected wallet.Login with SIWE
Parameters
The EIP-191 signature corresponding to the message.
The EIP-4361 message returned by
generateSiweMessage.Whether to disable signup for the login flow.
Returns
The authenticated user.
Usage
Callbacks
You can optionally pass callbacks intouseLoginWithSiwe to run custom logic after a successful login, or to handle errors that occur during the flow.onComplete
Parameters
The user object corresponding to the authenticated user.
Whether the user is a new user or an existing user.
Whether the user was already authenticated when the flow ran.
The method used by the user to login (if applicable).
The account corresponding to the login method.
onError
Parameters
The error that occurred during the login flow.
Usage
Tracking login flow state
Thestate variable returned from useLoginWithSiwe will always be one of the following values.Sign in with Ledger on Solana
Currently, Ledger Solana hardware wallets only support transaction signatures, not the message signatures required for Sign-In With Solana (SIWS) authentication. In order to authenticate with a Solana Ledger wallet, you must mount theuseSolanaLedgerPlugin hook inside your PrivyProvider.Critical: The
useSolanaLedgerPlugin hook must be placed inside a component that is
wrapped by PrivyProvider. If the hook is placed alongside or outside the PrivyProvider, it
will not function correctly.
