Create an instance of EcosystemWallet using a user's email, phone number or OAuth. This wallet type facilitates secure user authentication through OTP verification, making it suitable for client-facing applications where handling private keys directly is not ideal.
Login Methods
Ecosystem Wallets support a variety of login methods:
The ID of the ecosyste wallet you created on the dashboard.
ecosystemPartnerId (optional)
The partner ID you were provided by the Ecosystem owner.
email (optional)
The user's email address. Required if phoneNumber is not provided.
phoneNumber (optional)
The user's phone number. Required if email is not provided.
authProvider (optional)
The OAuth provider to use for authentication. Supported values are AuthProvider.Google, AuthProvider.Apple, AuthProvider.Facebook.
storageDirectoryPath (optional)
The path to the directory where the wallet data is stored. Defaults to the application's data directory.
siweSigner (optional)
An external wallet instance to use for SIWE authentication.
legacyEncryptionKey (optional)
The encryption key that is no longer required but was used in the past. Only pass this if you had used custom auth before this was deprecated.
walletSecret (optional)
The secret identifier to use when creating server-side wallets with backend authentication.
EcosystemWallet
Returns an instance of EcosystemWallet, initialized for the user based on the provided email or phone number. This wallet is ready for OTP authentication and further blockchain interactions.
OTP Authentication Flow
The OTP authentication flow involves sending an OTP to the user's email or phone and then verifying the OTP to complete authentication:
Send OTP: Initiate the login process by calling SendOTP on the EcosystemWallet instance. This sends an OTP to the user's email or phone number.
await wallet.SendOTP();
Submit OTP: Once the user receives the OTP, they submit it back to the application, which then calls LoginWithOtp on the EcosystemWallet instance to verify the OTP and complete the login process.
Note: EcosystemWallet leverages the security of OTP-based authentication to ensure a secure and user-friendly experience in blockchain applications.
OAuth Authentication Flow
LoginWithOauth: Initiate the login process by calling LoginWithOauth on the EcosystemWallet instance. This redirects the user to the OAuth provider's login page.
Note: The LoginWithOauth API allows for custom browser handling, making it suitable for various application types and platforms.
External Wallet Auth (Siwe & SiweExternal)
LoginWithSiwe: Initiate the login process by calling LoginWithSiwe on the EcosystemWallet instance. This will prompt the external wallet to sign a message instantly.
LoginWithSiweExternal: Initiate the login process by calling LoginWithSiweExternal on the EcosystemWallet instance. This will initiate a browser-based login flow for external wallets that only support web platforms.
varaddress=await wallet.LoginWithSiweExternal(
// Windows console app example, adaptable to any runtime
Note: The parameters are similar to the OAuth flow, with the addition of forceWalletIds to specify the wallet IDs to force the user to use. Using a single wallet id will skip the wallet selection screen and directly open the wallet.
Unified Identity - Account Linking
EcosystemWallet supports linking multiple authentication methods to a single user account. This feature enables users to access their account using different authentication methods, such as email, phone, or OAuth, without creating separate accounts for each method.