How to trigger delegation for a user using the JavaScript SDK.
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).
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 });
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.