Delegated access lets your backend sign for a user’s embedded wallet without a prompt every time — useful for automations, scheduled actions, or server-side flows the user has opted into. You’ll build:
Status — show whether delegated access is on.
Grant — turn it on, with the user’s explicit consent.
Only grant after clear, explicit consent — you’re letting your backend act on the user’s behalf. Pass the wallet password when your project protects wallets with one.
TypeScript
React
import { delegateWaasKeyShares } from '@dynamic-labs-sdk/client/waas';import type { WalletAccount } from '@dynamic-labs-sdk/client';async function grant(walletAccount: WalletAccount, password?: string) { await delegateWaasKeyShares({ password, walletAccount }); // showGranted is your implementation. showGranted();}
import type { WalletAccount } from '@dynamic-labs-sdk/client';import { useDelegateWaasKeyShares } from '@dynamic-labs-sdk/react-hooks';function GrantAccess({ walletAccount, password,}: { walletAccount: WalletAccount; password?: string;}) { const { mutateAsync: delegate, isPending } = useDelegateWaasKeyShares(); return ( <button type="button" disabled={isPending} // Pass password when your project protects wallets with one. onClick={() => delegate({ password, walletAccount })} > {isPending ? 'Enabling…' : 'Enable delegated access'} </button> );}
Delegated access means your backend can sign without the user present. Explain exactly what it enables, keep it opt-in, and make revoking easy.
import { revokeWaasDelegation } from '@dynamic-labs-sdk/client/waas';import type { WalletAccount } from '@dynamic-labs-sdk/client';async function revoke(walletAccount: WalletAccount, password?: string) { await revokeWaasDelegation({ password, walletAccount }); // showRevoked is your implementation. showRevoked();}
import type { WalletAccount } from '@dynamic-labs-sdk/client';import { useRevokeWaasDelegation } from '@dynamic-labs-sdk/react-hooks';function RevokeAccess({ walletAccount, password,}: { walletAccount: WalletAccount; password?: string;}) { const { mutateAsync: revoke, isPending } = useRevokeWaasDelegation(); return ( <button type="button" disabled={isPending} // Pass password when your project protects wallets with one. onClick={() => revoke({ password, walletAccount })} > {isPending ? 'Revoking…' : 'Revoke delegated access'} </button> );}