Summary
TheuseWalletDelegation
hook provides methods to trigger and manage the wallet delegation flow for Dynamic embedded wallets.
For more information on how wallet delegation works, see the delegated access documentation.
The hook needs to be initialized within a child of DynamicContextProvider.
Return Value
The hook returns an object with the following properties:Functions
initDelegationProcess
Initiates the wallet delegation flow by opening the Dynamic modal and displaying the delegation prompt to the user.
Parameters:
options
(optional): Configuration objectwallets
(optional): Array of specific wallets to delegate. If not provided, delegates all eligible MPC wallets.
Promise<void>
- Resolves when delegation completes successfully, rejects on failure.
Errors:
- Throws
"No primary wallet"
if the user doesn’t have a primary wallet connected - Throws
"user_not_logged_in"
if the user is not authenticated
shouldPromptWalletDelegation
Determines whether the user should be prompted for wallet delegation based on:
- Delegated access settings in project configuration
- User’s previous delegation decisions (denied or completed)
- Existence of undelegated MPC wallets
boolean
- true
if the user should see the delegation prompt, false
otherwise.
Example:
Properties
requiresDelegation
A boolean value from your project settings that indicates whether wallet delegation is required for your application.
Type: boolean | undefined
Example:
Usage
Advanced Usage
Delegate specific wallets:Important Notes
- The user must be authenticated and have a primary wallet for delegation to work
- The delegation modal is part of the Dynamic UI and handles all user interactions
- User delegation preferences are persisted across sessions using local storage