EVMSolana
After users enroll in MFA, they’ll see a prompt to enter their code whenever they perform sensitive operations like signing transactions or exporting keys. This page covers how to handle those prompts.
Choose your approach
Pre-built components
Drop-in React modals and inline UI. Best for most apps.
React hooks
Build custom verification UI. For full control over the verification flow.
Core SDK
Direct API calls. For non-React apps.
Ready-to-use components (recommended)
@coinbase/cdp-react provides ready-to-use components with a polished UI.
Pre-built components support both TOTP (authenticator apps) and SMS verification. When a user has multiple methods enrolled, the component shows a method selector automatically.
- Modal
- Programmatic
- Inline
UI Customization
For controlled modals, check the VerifyMfaModal component reference.
For custom layouts or render props, check the VerifyMfa component reference.
For inline flows with transitions, check the VerifyMfaInline component reference.
For controlled modals, check the VerifyMfaModal component reference.
For custom layouts or render props, check the VerifyMfa component reference.
For inline flows with transitions, check the VerifyMfaInline component reference.
Custom UIs using React Hooks
For custom UI or SMS verification, use hooks from@coinbase/cdp-hooks.
Verification is a two-step process:
- Initiate — Call
useInitiateMfaVerificationto start verification (for SMS, this sends a new code) - Submit — Call
useSubmitMfaVerificationwith the 6-digit code to complete verification
- TOTP
- SMS
- Multiple methods
For complete UI implementations with error handling and state management, see the MFA section in the cdp-hooks reference.
Direct API calls for non-React
For non-React applications, use functions from@coinbase/cdp-core.
- TOTP
- SMS
For full API details, see the cdp-core reference.
Handling MFA errors
When a sensitive operation requires MFA, it throws an error with codeMFA_REQUIRED:
Troubleshooting
Invalid TOTP code
Invalid TOTP code
Common causes:
- Time synchronization issues between device and server
- User entering an expired code (TOTP codes refresh every 30 seconds)
- Incorrect authenticator app setup
- Ensure device time is synchronized with network time
- Ask users to wait for a new code and try again
- Verify the QR code was scanned correctly during enrollment
Invalid SMS code
Invalid SMS code
Common causes:
- User entering an expired code (SMS codes expire after 5 minutes)
- User entering enrollment code instead of verification code
- Wrong phone number entered during enrollment
- Ensure user is entering the most recent code
- For verification, remind users they need to initiate verification first to receive a new SMS
- Provide resend option with rate limiting
- Allow users to re-enroll with correct phone number
User has multiple methods enrolled
User has multiple methods enrolled
Solution:
- Use
getEnrolledMfaMethods(user)to get available methods - Present UI to let user choose their preferred verification method
- Store user’s preference for future verifications
- See the “Multiple methods” tab above for implementation
Lost authenticator app or phone access
Lost authenticator app or phone access
Recovery options:
- If user has both TOTP and SMS enrolled, they can use the other method
- Implement account recovery through primary authentication method
- Allow MFA reset after verifying via email or other auth method
- Provide customer support flow for account recovery