Skip to main content
In your application, when a user is logged in, you’ll want to request delegation for your application.
Make sure you have configured delegated access in the dashboard before triggering delegation.

Dynamic’s UI

Auto-prompt User on Sign In

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.

Trigger Delegation Manually

You can use the initDelegationProcess method from the wallets module to open the delegation modal UI:
// Open the delegation modal for all eligible wallets
await DynamicSDK.instance.wallets.initDelegationProcess();

// Or specify which wallets to delegate
await DynamicSDK.instance.wallets.initDelegationProcess(
  walletIds: ['wallet-id-1', 'wallet-id-2'],
);

Check If User Should Be Prompted

Before prompting, you can check whether the user should see a delegation prompt:
final shouldPrompt = await DynamicSDK.instance.wallets.shouldPromptWalletDelegation();

if (shouldPrompt) {
  await DynamicSDK.instance.wallets.initDelegationProcess();
}

Your Own UI

You can use delegateKeyShares to delegate wallets programmatically without showing any Dynamic UI:
import 'package:dynamic_sdk/dynamic_sdk.dart';

// Delegate all eligible wallets
await DynamicSDK.instance.wallets.delegateKeyShares();

// Or delegate specific wallets
await DynamicSDK.instance.wallets.delegateKeyShares(
  wallets: [
    DelegationWalletIdentifier(
      chainName: ChainEnum.evm,
      accountAddress: '0x123...',
    ),
    DelegationWalletIdentifier(
      chainName: ChainEnum.sol,
      accountAddress: 'ABC123...',
    ),
  ],
);

Monitor Delegation State

You can observe delegation state changes reactively:
// Get current state synchronously
final state = DynamicSDK.instance.wallets.delegatedAccessState;
print('Enabled: ${state.delegatedAccessEnabled}');
print('Required: ${state.requiresDelegation}');

// Listen to state changes
DynamicSDK.instance.wallets.delegatedAccessChanges.listen((state) {
  for (final wallet in state.walletsDelegatedStatus) {
    print('${wallet.address}: ${wallet.status}');
  }
});

Check Wallet Delegation Status

// Get status of all wallets
final 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 wallet
final status = DynamicSDK.instance.wallets.getDelegationStatusForWallet('wallet-id');
if (status != null) {
  print('Status: ${status.status}'); // delegated, pending, or denied
}

Dismiss or Deny Delegation

// Dismiss the prompt for the current session only (resets on logout/restart)
await DynamicSDK.instance.wallets.dismissDelegationPrompt();

// Or dismiss for a specific wallet
await 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 dismissals
await DynamicSDK.instance.wallets.clearDelegationSessionState();

What's next?

Learn how to properly receive the delegation materials on your server