Enable wallet authentication in the Privy
Dashboard before implementing this feature.
To authenticate a user via an Ethereum wallet (SIWE) without Privy UIs, use the React SDK’s
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.