Wallet
For users who already have wallets, Privy supports signing in with Ethereum (SIWE) or Solana (SIWS). With this flow, users who are already onchain can bring their existing wallet to your app, verify ownership of assets, and take onchain actions.
To have users login to your app with a wallet, use the login
method from the usePrivy
hook.
Login with wallet is only available using Privy UIs.
Parameters
The login methods to enable.
The chain type of the wallet to login with.
Whether to disable signup for the login method.
Returns
This method does not return anything.
Usage
To have users login to your app with a wallet, use the login
method from the usePrivy
hook.
Login with wallet is only available using Privy UIs.
Parameters
The login methods to enable.
The chain type of the wallet to login with.
Whether to disable signup for the login method.
Returns
This method does not return anything.
Usage
To authenticate a user via an Ethereum wallet (SIWE), use the React Native SDK’s useLoginWithSiwe
hook.
In order to use Privy’s login with wallet flow, users must actively have an ethereum wallet connected to your app from which you can request signatures.
Generate SIWE message
Parameters
Wallet object containing EIP-55 compliant wallet address and chainId in CAIP-2 format.
Origin object containing domain and uri.
Returns
A SIWE message that can be signed by the wallet.
Usage
Sign the SIWE message
Then, request an EIP-191 personal_sign
signature for the message
returned by generateSiweMessage
, from a connected wallet.
There are many ways to connect a wallet to a mobile app, a few good options are:
Login with SIWE
Parameters
The signature of the SIWE message, signed by the user’s wallet.
An optional override for the message that is signed.
If true, the user will not be automatically created if they do not exist in the Privy database.
Returns
A PrivyUser object containing the user’s information.
Usage
Callbacks
You can optionally pass callbacks into the useLoginWithSiwe
hook to run custom logic after a message has been generated, after a successful login, or to handle errors that occur during the flow.
onGenerateMessage
Parameters
The SIWE message that was generated.
onSuccess
Parameters
The user object corresponding to the authenticated user.
Whether the user is a new user or an existing user.
onError
Parameters
The error that occurred during the login flow.
Usage
Tracking login flow state
The state
variable returned from useLoginWithSiwe
will always be one of the following values.
To authenticate a user via an Ethereum wallet (SIWE), use the React Native SDK’s useLoginWithSiwe
hook.
In order to use Privy’s login with wallet flow, users must actively have an ethereum wallet connected to your app from which you can request signatures.
Generate SIWE message
Parameters
Wallet object containing EIP-55 compliant wallet address and chainId in CAIP-2 format.
Origin object containing domain and uri.
Returns
A SIWE message that can be signed by the wallet.
Usage
Sign the SIWE message
Then, request an EIP-191 personal_sign
signature for the message
returned by generateSiweMessage
, from a connected wallet.
There are many ways to connect a wallet to a mobile app, a few good options are:
Login with SIWE
Parameters
The signature of the SIWE message, signed by the user’s wallet.
An optional override for the message that is signed.
If true, the user will not be automatically created if they do not exist in the Privy database.
Returns
A PrivyUser object containing the user’s information.
Usage
Callbacks
You can optionally pass callbacks into the useLoginWithSiwe
hook to run custom logic after a message has been generated, after a successful login, or to handle errors that occur during the flow.
onGenerateMessage
Parameters
The SIWE message that was generated.
onSuccess
Parameters
The user object corresponding to the authenticated user.
Whether the user is a new user or an existing user.
onError
Parameters
The error that occurred during the login flow.
Usage
Tracking login flow state
The state
variable returned from useLoginWithSiwe
will always be one of the following values.
To authenticate a user via a Solana wallet (SIWS), use the React Native SDK’s useLoginWithSiws
hook.
In order to use Privy’s login with wallet flow, users must actively have a Solana wallet connected to your app from which you can request signatures.
Generate SIWS message
Parameters
Wallet object containing Solana wallet address.
Origin object containing domain and uri.
Returns
A SIWS message that can be signed by the wallet.
Usage
Sign the SIWS message
Then, request a signature for the message
returned by generateMessage
, from a connected wallet.
Login with SIWS
Parameters
The signature of the SIWS message, signed by the user’s wallet.
The original message that was signed.
If true, the user will not be automatically created if they do not exist in the Privy database.
Returns
A PrivyUser object containing the user’s information.
Usage
To authenticate a user via an Ethereum wallet (SIWE), use the Privy client’s siwe
handler.
Generate SIWE message
Parameters
Set of parameters required to generate the message.
Returns
A SIWE message that can be signed by the wallet.
Usage
Sign the SIWE message
Using the message returned by generateSiweMessage
, request an EIP-191 personal_sign
signature from the user’s connected wallet. You should do this using the library your app uses to connect to external wallets (e.g. the MetaMask iOS SDK or WalletConnect).
Once the user successfully signs the message, store the signature in a variable.
Login with SIWE
Parameters
The message returned from “generateSiweMessage”.
The signature of the SIWE message, signed by the user’s wallet.
The same SiweMessageParams passed into “generateSiweMessage”.
(Optional) you can pass additional metadata that will be stored with the linked wallet.
Returns
The authenticated Privy user
Throws
An error if logging the user in is unsuccessful.
Usage
To authenticate a user via an Ethereum wallet (SIWE), use the Privy client’s siwe
handler.
Generate SIWE message
Parameters
Set of parameters required to generate the message.
Returns
A SIWE message that can be signed by the wallet.
Usage
Sign the SIWE message
Using the message returned by generateSiweMessage
, request an EIP-191 personal_sign
signature from the user’s connected wallet. You should do this using the library your app uses to connect to external wallets (e.g. the MetaMask iOS SDK or WalletConnect).
Once the user successfully signs the message, store the signature in a variable.
Login with SIWE
Parameters
The message returned from “generateSiweMessage”.
The signature of the SIWE message, signed by the user’s wallet.
The same SiweMessageParams passed into “generateSiweMessage”.
(Optional) you can pass additional metadata that will be stored with the linked wallet.
Returns
The authenticated Privy user
Throws
An error if logging the user in is unsuccessful.