Summary

The useUpgradeToDynamicWaasFlow hook provides a programmatic way to prompt users to upgrade their existing wallets to Dynamic’s advanced MPC v3 wallets with Wallet-as-a-Service (WaaS) functionality. This hook opens the upgrade flow modal and navigates users through the process of migrating to enhanced wallet capabilities. The hook needs to be initialized within a child of DynamicContextProvider.

Usage

Available functions:
MethodTypeDescription
promptUpgradeToDynamicWaasFlow() => voidOpens the upgrade flow modal to migrate to Dynamic WaaS wallets

Return Value

The hook returns an object with the following property:
  • promptUpgradeToDynamicWaasFlow: A function that when called, opens the auth flow modal and navigates to the WaaS upgrade view

What is WaaS Upgrade?

Dynamic’s Wallet-as-a-Service (WaaS) upgrade allows users to migrate from standard wallets to advanced MPC v3 wallets that provide:
  • Enhanced security with multi-party computation (MPC)
  • Advanced key management capabilities
  • Improved backup and recovery options
  • Enterprise-grade wallet infrastructure

Example

import { useUpgradeToDynamicWaasFlow } from '@dynamic-labs/sdk-react-core';

const UpgradeWalletButton = () => {
  const { promptUpgradeToDynamicWaasFlow } = useUpgradeToDynamicWaasFlow();

  return (
    <button
      onClick={() => promptUpgradeToDynamicWaasFlow()}
      className="upgrade-btn"
    >
      Upgrade to Advanced Wallet
    </button>
  );
};

Advanced Example with User State Check

import { useUpgradeToDynamicWaasFlow, useDynamicContext } from '@dynamic-labs/sdk-react-core';

const ConditionalUpgradeComponent = () => {
  const { promptUpgradeToDynamicWaasFlow } = useUpgradeToDynamicWaasFlow();
  const { user, primaryWallet } = useDynamicContext();

  // Check if user is eligible for upgrade
  const isEligibleForUpgrade = user && primaryWallet && primaryWallet.key !== 'dynamicwaas';

  const handleUpgrade = () => {
    if (isEligibleForUpgrade) {
      promptUpgradeToDynamicWaasFlow();
    }
  };

  if (!isEligibleForUpgrade) {
    return null; // Don't show upgrade option if not eligible
  }

  return (
    <div className="upgrade-container">
      <h3>Upgrade Your Wallet</h3>
      <p>Get enhanced security and features with Dynamic WaaS</p>
      <button onClick={handleUpgrade}>
        Start Upgrade Process
      </button>
    </div>
  );
};

Error Handling

The hook will throw errors in the following scenarios:
  • Missing context: If used outside of DynamicContextProvider
  • Context method failures: If internal context methods (setShowAuthFlow or pushView) fail
import { useUpgradeToDynamicWaasFlow } from '@dynamic-labs/sdk-react-core';

const SafeUpgradeComponent = () => {
  const { promptUpgradeToDynamicWaasFlow } = useUpgradeToDynamicWaasFlow();

  const handleUpgrade = async () => {
    try {
      promptUpgradeToDynamicWaasFlow();
    } catch (error) {
      console.error('Failed to start upgrade flow:', error);
      // Handle error appropriately (show user message, retry logic, etc.)
    }
  };

  return (
    <button onClick={handleUpgrade}>
      Upgrade Wallet
    </button>
  );
};

See Also