Skip to content

Revoking delegated wallets

Once a user has delegated their wallets, they may also revoke consent to prevent your app from taking any further wallet actions on their behalf.

You can revoke a user's delegated wallets with a revocation screen (with UIs) or automatically (without UIs).

To prompt users to revoke delegated wallets with a revocation screen, use the revokeWallets method from the useDelegatedActions hook:

tsx
import {useDelegatedActions} from '@privy-io/expo';
...
const {revokeWallets} = useDelegatedActions();

When invoked, the revokeWallets method will open a Privy modal where the user can either confirm the revocation of their delegated wallets. If the user has no delegated wallets, this method will error.

Once a user confirms revocation, your app will no longer be able to take actions on behalf of the user with their wallet unless the user delegates actions again.

If a user has delegated multiple embedded wallets, they will all be revoked.

As an example, you might have a button within your app to allow users to revoke delegated actions like so:

tsx
import {usePrivy, useDelegatedActions, getAllUserEmbeddedEthereumWallets} from '@privy-io/expo';

function RevokeDelegateActionButton() {
  const {user} = usePrivy();
  const {revokeWallets} = useDelegatedActions();
  const wallets = getAllUserEmbeddedEthereumWallets(user); // or getAllUserEmbeddedSolanaWallets

  // Check if the user has any delegated wallets by searching the user's wallets for any with
  // `delegated: true` set.
  const hasDelegatedWallets = wallets.some((wallet) => wallet.delegated);

  const onRevoke = async () => {
    if (!hasDelegatedWallets) return; // Button is disabled to prevent this case
    await revokeWallets();
  };

  return (
    <button disabled={!hasDelegatedWallets} onClick={onRevoke}>
      Revoke permission for this app to transact on my behalf
    </button>
  );
}