user
state in your client and the user object
you might query from your server.
This enables you to easily associate smart account addresses with users.useLinkWithSiwe
hook from @privy-io/react-auth
. This hook allows you to generate a SIWE message for an arbitrary wallet and pass the resulting signature for verification.
generateSiweMessage
method returned by the hook to generate a SIWE message for the smart account to sign. As parameters to this method, pass an object with the following fields:
Parameter | Type | Description |
---|---|---|
address | string | Required. The user’s smart account address. Must be properly checksummed per EIP-55. |
chainId | number | Required. The chain ID of the smart account. Must be a CAIP-2 formatted chain ID that correspond to a valid network where signatures from the smart account can be verified. |
chainId
you pass to generateSiweMessage
and linkWithSiwe
is
CAIP-2 formatted.personal_sign
signature from the smart accountmessage
you generated in step (1), request a EIP191 personal_sign
signature from the smart account.
The interface for requesting this signature may depend on which smart account provider (ZeroDev, Pimlico, Safe, Biconomy, Alchemy your app uses; see the corresponding guides to understand the best way to request a signature from the wallet.
signature
from the smart account to Privy using the linkWithSiwe
method returned by the useLinkWithSiwe
hook. As parameters to this method, include an object with the following fields:
Parameter | Type | Description |
---|---|---|
message | string | Required. The SIWE message you generated with generateSiweMessage . |
chainId | number | Required. The CAIP-2 chain ID you passed to generateSiweMessage . |
signature | string | Required. The signature produced by the smart account. |
walletClientType | string | Recommended. A signature indicating the wallet client you’d like to associate with the smart account. We recommend using 'privy_smart_account' . |
connectorType | string | Recommended. A signature indicating the connector type you’d like to associate with the smart account. We recommend using the snake_cased name of your smart account provider, e.g. 'zerodev' . |
user
object. Simply inspect the linkedAccounts
array for the entry with:
type: 'wallet'
walletClientType: 'privy_smart_account'
, or any other custom walletClientType
you choselinked_accounts
array.