Authenticate a connected wallet
Once a user has connected their wallet to your app, and the wallet is available in the useWallets
or useSolanaWallets
array, you can also prompt them to login with that wallet or link that wallet to their existing account, instead of prompting the entire login
or linkWallet
flow.
To do so, find the ConnectedWallet
or ConnectedSolanaWallet
object from Privy, and call the object’s loginOrLink
method:
When called, loginOrLink
will directly request a SIWE or SIWS signature from the user’s connected wallet to authenticate the wallet.
If the user was not authenticated
when the method was called, the user will become authenticated
after signing the message.
If the user was already authenticated
when the method was called, the user will remain authenticated
after signing the message, and the connected wallet will become one of the user’s linkedAccounts
in their user
object.
You might use the methods above to “split up” the connect and sign steps of external wallet login, like so:
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 will need to mount the following hook in your application:
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.
Once a user has connected their wallet to your app, and the wallet is available in the useWallets
or useSolanaWallets
array, you can also prompt them to login with that wallet or link that wallet to their existing account, instead of prompting the entire login
or linkWallet
flow.
To do so, find the ConnectedWallet
or ConnectedSolanaWallet
object from Privy, and call the object’s loginOrLink
method:
When called, loginOrLink
will directly request a SIWE or SIWS signature from the user’s connected wallet to authenticate the wallet.
If the user was not authenticated
when the method was called, the user will become authenticated
after signing the message.
If the user was already authenticated
when the method was called, the user will remain authenticated
after signing the message, and the connected wallet will become one of the user’s linkedAccounts
in their user
object.
You might use the methods above to “split up” the connect and sign steps of external wallet login, like so:
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 will need to mount the following hook in your application:
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.