Skip to main content
In your application, when a user is logged in, you’ll want to request delegation so your server can act on their behalf (for example, to sign transactions or run automated flows).

Check delegation status

Use hasDelegatedAccess to check whether a wallet account already has delegated access before triggering the delegation flow.
import { getWalletAccounts } from '@dynamic-labs-sdk/client';
import { hasDelegatedAccess } from '@dynamic-labs-sdk/client/waas';

const walletAccounts = getWalletAccounts();
const walletAccount = walletAccounts[0];

const isDelegated = hasDelegatedAccess({ walletAccount });
console.log('Has delegated access:', isDelegated);

Trigger delegation

Use delegateWaasKeyShares to initiate the delegation process for a wallet account. This sends the encrypted delegated share to your server via the wallet.delegation.created webhook.
import { getWalletAccounts } from '@dynamic-labs-sdk/client';
import { delegateWaasKeyShares } from '@dynamic-labs-sdk/client/waas';

const walletAccounts = getWalletAccounts();
const walletAccount = walletAccounts[0];

await delegateWaasKeyShares({ walletAccount });

With password encryption

If the wallet uses password encryption, pass the password when delegating. The delegated share will be encrypted with the password before being sent.
import { getWalletAccounts } from '@dynamic-labs-sdk/client';
import { delegateWaasKeyShares } from '@dynamic-labs-sdk/client/waas';

const walletAccounts = getWalletAccounts();
const walletAccount = walletAccounts[0];

await delegateWaasKeyShares({ walletAccount, password: 'user-password' });
Dynamic does not prompt the user for a password during delegation. If the wallet is password-protected, you must obtain the password in your own UI flow and pass it programmatically.

Parameters

ParameterTypeRequiredDescription
walletAccountWalletAccountYesThe WaaS wallet account to delegate
passwordstringNoPassword for wallets using password encryption

What's next?

Learn how to receive the delegation materials on your server