If you chose to prompt the user on sign in during the configuration step, the user is prompted to approve delegation for your application when they next sign in.
You can use the initDelegationProcess method from the wallets module to open the delegation modal UI:
// Open the delegation modal for all eligible walletsawait DynamicSDK.instance.wallets.initDelegationProcess();// Or specify which wallets to delegateawait DynamicSDK.instance.wallets.initDelegationProcess( walletIds: ['wallet-id-1', 'wallet-id-2'],);
You can observe delegation state changes reactively:
// Get current state synchronouslyfinal state = DynamicSDK.instance.wallets.delegatedAccessState;print('Enabled: ${state.delegatedAccessEnabled}');print('Required: ${state.requiresDelegation}');// Listen to state changesDynamicSDK.instance.wallets.delegatedAccessChanges.listen((state) { for (final wallet in state.walletsDelegatedStatus) { print('${wallet.address}: ${wallet.status}'); }});
// Get status of all walletsfinal statuses = await DynamicSDK.instance.wallets.getWalletsDelegatedStatus();for (final status in statuses) { print('Wallet ${status.address} on ${status.chain}: ${status.status}');}// Get status for a specific walletfinal status = DynamicSDK.instance.wallets.getDelegationStatusForWallet('wallet-id');if (status != null) { print('Status: ${status.status}'); // delegated, pending, or denied}
// Dismiss the prompt for the current session only (resets on logout/restart)await DynamicSDK.instance.wallets.dismissDelegationPrompt();// Or dismiss for a specific walletawait DynamicSDK.instance.wallets.dismissDelegationPrompt(walletId: 'wallet-id');// Permanently deny delegation for a wallet (user won't be prompted again)await DynamicSDK.instance.wallets.denyWalletDelegation(walletId: 'wallet-id');// Clear all session dismissalsawait DynamicSDK.instance.wallets.clearDelegationSessionState();
What's next?
Learn how to properly receive the delegation materials on your server