Advanced configuration
The Embedded Wallets SDK provides extensive configuration options that allow you to customize authentication flows, UI appearance, blockchain integrations, and security features to meet your application's specific requirements.
Configuration structure
When setting up Embedded Wallets, you'll pass in the options to the constructor. This consists of:
import 'package:web3auth_flutter/web3auth_flutter.dart';
import 'package:web3auth_flutter/enums.dart';
import 'package:web3auth_flutter/input.dart';
import 'package:web3auth_flutter/output.dart';
import 'dart:io';
Future<void> initWeb3Auth() async {
late final String redirectUrl;
if (Platform.isAndroid) {
redirectUrl = 'w3a://com.example.w3aflutter';
} else {
redirectUrl = 'com.example.w3aflutter://auth';
}
await Web3AuthFlutter.init(Web3AuthOptions(
clientId: "YOUR_WEB3AUTH_CLIENT_ID", // Pass your Web3Auth Client ID, ideally using an environment variable // Get your Client ID from MetaMask Developer Dashboard dashboard
web3AuthNetwork: Web3AuthNetwork.sapphire_mainnet, // or Web3AuthNetwork.sapphire_devnet
redirectUrl: redirectUrl,
));
}
Web3AuthOptions
The Web3Auth Constructor takes an object with Web3AuthOptions as input.
- Table
- Class
| Parameter | Description |
|---|---|
clientId | Your Web3Auth Client ID from the Dashboard. Mandatory String. |
web3AuthNetwork | Web3Auth Network: sapphire_mainnet, sapphire_devnet, mainnet, cyan, aqua, or testnet. Mandatory Web3AuthNetwork. |
redirectUrl | URL that Web3Auth redirects to after successful authentication. Mandatory String. |
whiteLabel? | Whitelabel options for custom UI, branding, and translations. Takes WhiteLabelData as a value. |
authConnectionConfig? | Auth connection config for custom connections. Takes List<AuthConnectionConfig> as a value. |
chains? | Chain configuration for Wallet Services and signing. Takes List<Chains> as a value. |
defaultChainId? | Default chain ID from the chains list. |
mfaSettings? | Configure MFA settings for authentication. Takes MfaSettings as a value. |
sessionTime? | Configure session management time in seconds. Default is 30 days. Max 30 days. |
class Web3AuthOptions {
final String clientId;
final Web3AuthNetwork web3AuthNetwork;
final BuildEnv? authBuildEnv;
final String redirectUrl;
final WhiteLabelData? whiteLabel;
final List<AuthConnectionConfig>? authConnectionConfig;
final List<Chains>? chains;
final String? defaultChainId;
final bool? useSFAKey;
final MfaSettings? mfaSettings;
final int sessionTime;
Web3AuthOptions({
required this.clientId,
required this.web3AuthNetwork,
this.authBuildEnv = BuildEnv.production,
required this.redirectUrl,
this.whiteLabel,
this.authConnectionConfig = const [],
this.chains,
this.defaultChainId,
this.useSFAKey = false,
this.sessionTime = 30 * 86400,
this.mfaSettings,
});
}
Session management
Control how long users stay authenticated and how sessions persist. The session key is stored in the device's encrypted Keystore.
Key Configuration Options:
sessionTime- Session duration in seconds. Controls how long users remain authenticated before needing to log in again.- Minimum: 1 second (
1). - Maximum: 30 days (
86400 * 30). - Default: 30 days (
30 * 86400).
- Minimum: 1 second (
await Web3AuthFlutter.init(Web3AuthOptions(
clientId: "YOUR_WEB3AUTH_CLIENT_ID", // Pass your Web3Auth Client ID, ideally using an environment variable // Get your Client ID from MetaMask Developer Dashboard dashboard
web3AuthNetwork: Web3AuthNetwork.sapphire_mainnet, // or Web3AuthNetwork.sapphire_devnet
sessionTime: 30 * 86400, // 30 days (in seconds)
redirectUrl: redirectUrl,
));
Custom authentication methods
Control the login options presented to your users. For detailed configuration options and implementation examples, see the custom authentication section.
UI customization
Customize the brand experience by customizing the Web3Auth Login Screens to match your application's design. For complete customization options, refer to the whitelabeling and UI customization section.
Multi-Factor Authentication (MFA)
Add additional security layers to protect user accounts with two-factor authentication. See the detailed configuration options and implementation examples.
Key Configuration Options:
mfaSettings- Configure MFA settings for different authentication flowsmfaLevel- Control when users are prompted to set up MFA