Skip to main content
In your application, when a user is logged in, you’ll want to request delegation for your application.

Using the Client API

You can use the Dynamic client’s delegation module to trigger delegation programmatically:
import { createClient } from '@dynamic-labs/client';
import { ChainEnum } from '@dynamic-labs/sdk-api-core';

const client = createClient({
  environmentId: 'your-environment-id',
  // ... other config
});

// Trigger delegation for all user wallets
await client.wallets.waas.delegation.initDelegationProcess({});

// Or trigger delegation for specific wallets
await client.wallets.waas.delegation.initDelegationProcess({
  walletIds: ['wallet-id-1', 'wallet-id-2'],
});

// Check if delegation prompt should be shown
const shouldPrompt = await client.wallets.waas.delegation.shouldPromptWalletDelegation();

// Get delegation status for all wallets
const walletsStatus = await client.wallets.waas.delegation.getWalletsDelegatedStatus();

Delegate Key Shares

You can delegate key shares for specific wallets with optional password encryption:
// Delegate without password
await client.wallets.waas.delegation.delegateKeyShares({
  wallets: [
    { chainName: ChainEnum.Evm, accountAddress: '0x123...' },
    { chainName: ChainEnum.Sol, accountAddress: 'abc...' },
  ],
});

// Delegate with password encryption
await client.wallets.waas.delegation.delegateKeyShares({
  wallets: [
    { chainName: ChainEnum.Evm, accountAddress: '0x123...' },
  ],
  password: 'secure-password',
});
When a password is provided, the delegated share will be encrypted with the password, providing an additional layer of security. Learn more about password encryption.

Available Delegation Methods

MethodDescription
initDelegationProcessInitiates the delegation process for specified wallets or all user wallets
shouldPromptWalletDelegationChecks if the user should be prompted for delegation
getWalletsDelegatedStatusReturns delegation status for all user wallets
delegateKeySharesDelegates key shares for specific wallets (with optional password)
revokeDelegationRevokes delegation for specific wallets (with optional password)
denyWalletDelegationDenies delegation for a specific wallet
dismissDelegationPromptDismisses the delegation prompt for a wallet
clearDelegationSessionStateClears delegation session state

What's next?

Learn how to properly receive the delegation materials