useSessionKeySigner
This hook returns a session key signer based on the provided session data and private key. The signer is used to interact with smart sessions and execute permissioned actions.
Returns:
Property
Type
Description
data
SafeSigner<"safeSmartSessionsSigner"> or undefined
The session key signer if it was successfully created, otherwise undefined.
error
Error or null
An error object if the signer creation failed, otherwise null.
isPending
boolean
A boolean indicating whether the signer is currently being created.
isSuccess
boolean
A boolean indicating whether the session key signer was successfully created.
isError
boolean
A boolean indicating whether an error occurred during the signer creation.
Usage Example:
How It Works:
The hook follows these steps to create the session key signer:
1. Uses the smartAccountClient obtained from useSmartAccount.
2. Extends the client using smartSessionActions and erc7579Actions.
3. Converts the smart account into a session signer using the toSmartSessionsSigner utility.
4. Returns the signer, which can then be used to sign permissioned operations.
Example of Expected Response:
Error Handling:
If an error occurs during the creation of the session key signer, the error object will provide information about what went wrong. This can be used to display helpful error messages to the user.
Customization:
The query is controlled using wagmi’s useQuery. You can pass additional options (e.g., enabling/disabling the query dynamically) as needed.
Last updated