InAppWallet.Create

Create an instance of InAppWallet 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

In-App Wallets support a variety of login methods:

  • Email (OTP Login)
  • Phone (OTP Login)
  • Socials (Google, Apple, Facebook, Telegram, Farcaster, Line, Github, Twitch, Steam etc.)
  • Custom Auth (OIDC Compatible)
  • Custom Auth (Generic Auth Endpoint)
  • Guest (Onboard easily, link other accounts later)
  • Backend (Server Wallets)
  • Siwe (Login with a seperate wallet supported by the SDK)
  • SiweExternal (Login with an external wallet that only supports web using a browser loading a static thirdweb React page temporarily)

Usage

// Email
var wallet = await InAppWallet.Create(client: client, email: "userEmail");
// Phone
var wallet = await InAppWallet.Create(client: client, phoneNumber: "+1234567890");
// Google, Apple, Facebook, etc.
var wallet = await InAppWallet.Create(client: client, authProvider: AuthProvider.Google);
// Custom Auth - JWT
var wallet = await InAppWallet.Create(client: client, authProvider: AuthProvider.JWT);
// Custom Auth - AuthEndpoint
var wallet = await InAppWallet.Create(client: client, authProvider: AuthProvider.AuthEndpoint);
// Guest Login
var wallet = await InAppWallet.Create(client: client, authProvider: AuthProvider.Guest);
// Server Login
var wallet = await InAppWallet.Create(client: client, authProvider: AuthProvider.Backend, walletSecret: "very-secret");
// Siwe
var wallet = await InAppWallet.Create(client: client, authProvider: AuthProvider.Siwe, siweSigner: anyExternalWallet);
// SiweExternal
var wallet = await InAppWallet.Create(client: client, authProvider: AuthProvider.SiweExternal);
// Session resuming supported for all methods
var isConnected = await wallet.IsConnected();
// If not connected, initiate login flow based on the auth provider you are using
// Email & Phone (OTP)
await wallet.SendOTP(); // and fetch the otp
var address = await wallet.LoginWithOtp("userEnteredOTP"); // try catch and retry if needed
// Socials (OAuth)
var address = await wallet.LoginWithOauth(
// Windows console app example, adaptable to any runtime
isMobile: false,
browserOpenAction: (url) =>
{
var psi = new ProcessStartInfo { FileName = url, UseShellExecute = true };
_ = Process.Start(psi);
},
mobileRedirectScheme: "myBundleId://"
);
// Custom Auth (JWT)
var address = await wallet.LoginWithCustomAuth(jwt: "myjwt");
// Custom Auth (AuthEndpoint)
var address = await wallet.LoginWithAuthEndpoint(payload: "mypayload");
// Guest Login (Easy onboarding)
var address = await wallet.LoginWithGuest();
// Backend (Server Wallets)
var address = await wallet.LoginWithBackend();
// SIWE (Wallet)
var address = await siweWallet.LoginWithSiwe(chainId: 1);
// SiweExternal (React-only wallet)
var address = await wallet.LoginWithSiweExternal(
// Windows console app example, adaptable to any runtime
isMobile: false,
browserOpenAction: (url) =>
{
var psi = new ProcessStartInfo { FileName = url, UseShellExecute = true };
_ = Process.Start(psi);
},
forceWalletIds: new List<string> { "io.metamask", "com.coinbase.wallet", "xyz.abs" }
);

Authentication, Linking and more.

InAppWallet extends EcosystemWallet, refer to the EcosystemWallet documentation for information about authentication, linking multiple auth providers to the same wallet, and more. All functionality outside of creation and third-party integrations is the same as EcosystemWallet.