Enrolling in MFA does not automatically verify the user for wallet operations. Once enrolled,
subsequent wallet actions will require MFA verification. See the verification
guides for how to complete MFA
verification.
- React
- React Native
- Swift
Setup
To enroll users in MFA with TOTP, use theinitEnrollmentWithTotp and submitEnrollmentWithTotp methods returned by the useMfaEnrollment hook:Initiating enrollment
First, initiate enrollment by calling Privy’sinitEnrollmentWithTotp method with no parameters. This method returns a Promise for an authUrl and secret that the user will need in order to complete enrollment.- Display the TOTP
authUrlas a QR code to the user, and prompt them to scan it with their TOTP client (commonly, a mobile app like Google Authenticator or Authy) - Allow the user to copy the TOTP
secretand paste it into their TOTP client
Completing enrollment
Once your user has successfully scanned the QR code, an enrollment code for Privy will appear within their TOTP client. Prompt the user to enter this code in your app, and call Privy’ssubmitEnrollmentWithTotp method. As a parameter, pass a JSON object with an mfaCode field that contains the MFA code from the user as a string.See an end-to-end example of enrolling users in MFA with TOTP
See an end-to-end example of enrolling users in MFA with TOTP
The component below serves as a reference implementation for how to enroll your users in MFA with TOTP!
Example enrolling a TOTP client for MFA

