Table of Contents

Class InAppWallet

Namespace
Thirdweb
Assembly
Thirdweb.dll

Represents an in-app wallet that extends the functionality of a private key wallet.

public class InAppWallet : PrivateKeyWallet, IThirdwebWallet
Inheritance
InAppWallet
Implements
Inherited Members
Extension Methods

Methods

Create(ThirdwebClient, string, string, AuthProvider, string, IThirdwebWallet)

Creates a new instance of the InAppWallet class.

public static Task<InAppWallet> Create(ThirdwebClient client, string email = null, string phoneNumber = null, AuthProvider authProvider = AuthProvider.Default, string storageDirectoryPath = null, IThirdwebWallet siweSigner = null)

Parameters

client ThirdwebClient

The Thirdweb client instance.

email string

The email address for Email OTP authentication.

phoneNumber string

The phone number for Phone OTP authentication.

authProvider AuthProvider

The authentication provider to use.

storageDirectoryPath string

The path to the storage directory.

siweSigner IThirdwebWallet

The SIWE signer wallet for SIWE authentication.

Returns

Task<InAppWallet>

A task that represents the asynchronous operation. The task result contains the created in-app wallet.

Exceptions

ArgumentException

Thrown when required parameters are not provided.

Disconnect()

Disconnects the wallet.

public override Task Disconnect()

Returns

Task

A task representing the asynchronous operation.

GetEmail()

Gets the email associated with the in-app wallet.

public Task<string> GetEmail()

Returns

Task<string>

A task representing the asynchronous operation. The task result contains the email address.

GetLinkedAccounts()

public Task<List<LinkedAccount>> GetLinkedAccounts()

Returns

Task<List<LinkedAccount>>

GetPhoneNumber()

Gets the phone number associated with the in-app wallet.

public Task<string> GetPhoneNumber()

Returns

Task<string>

A task representing the asynchronous operation. The task result contains the phone number.

LinkAccount(InAppWallet, string, bool?, Action<string>, string, IThirdwebBrowser, BigInteger?, string, string)

public Task<List<LinkedAccount>> LinkAccount(InAppWallet walletToLink, string otp = null, bool? isMobile = null, Action<string> browserOpenAction = null, string mobileRedirectScheme = "thirdweb://", IThirdwebBrowser browser = null, BigInteger? chainId = null, string jwt = null, string payload = null)

Parameters

walletToLink InAppWallet
otp string
isMobile bool?
browserOpenAction Action<string>
mobileRedirectScheme string
browser IThirdwebBrowser
chainId BigInteger?
jwt string
payload string

Returns

Task<List<LinkedAccount>>

LoginWithAuthEndpoint(string, string)

Logs in with an authentication endpoint.

public Task<string> LoginWithAuthEndpoint(string payload, string encryptionKey)

Parameters

payload string

The payload to use for authentication.

encryptionKey string

The encryption key to use.

Returns

Task<string>

A task representing the asynchronous operation. The task result contains the login result.

Exceptions

ArgumentException

Thrown when payload or encryption key is not provided.

Exception

Thrown when the login fails.

LoginWithGuest()

public Task<string> LoginWithGuest()

Returns

Task<string>

LoginWithJWT(string, string)

Logs in with a JWT.

public Task<string> LoginWithJWT(string jwt, string encryptionKey)

Parameters

jwt string

The JWT to use for authentication.

encryptionKey string

The encryption key to use.

Returns

Task<string>

A task representing the asynchronous operation. The task result contains the address.

Exceptions

ArgumentException

Thrown when JWT or encryption key is not provided.

Exception

Thrown when the login fails.

LoginWithOauth(bool, Action<string>, string, IThirdwebBrowser, CancellationToken)

Logs in with OAuth2.

public virtual Task<string> LoginWithOauth(bool isMobile, Action<string> browserOpenAction, string mobileRedirectScheme = "thirdweb://", IThirdwebBrowser browser = null, CancellationToken cancellationToken = default)

Parameters

isMobile bool

Indicates if the login is from a mobile device.

browserOpenAction Action<string>

The action to open the browser.

mobileRedirectScheme string

The mobile redirect scheme.

browser IThirdwebBrowser

The browser instance.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<string>

A task representing the asynchronous operation. The task result contains the login result.

Exceptions

ArgumentNullException

Thrown when required parameters are not provided.

TaskCanceledException

Thrown when the operation is canceled.

TimeoutException

Thrown when the operation times out.

LoginWithOtp(string)

Submits the OTP for verification.

public Task<(string address, bool canRetry)> LoginWithOtp(string otp)

Parameters

otp string

The OTP to submit.

Returns

Task<(string address, bool canRetry)>

A task representing the asynchronous operation. The task result contains the address and a boolean indicating if retry is possible.

Exceptions

ArgumentNullException

Thrown when OTP is not provided.

Exception

Thrown when email or phone number is not provided.

LoginWithSiwe(BigInteger)

Logs in with SIWE (Sign-In with Ethereum).

public Task<string> LoginWithSiwe(BigInteger chainId)

Parameters

chainId BigInteger

The chain ID to use for signing the SIWE payload

Returns

Task<string>

A task representing the asynchronous operation. The task result contains the address.

Exceptions

ArgumentNullException

Thrown when external wallet is not provided.

InvalidOperationException

Thrown when the external wallet is not connected.

ArgumentException

Thrown when chain ID is invalid.

SendOTP()

Sends an OTP to the user's email or phone number.

public Task<(bool isNewUser, bool isNewDevice)> SendOTP()

Returns

Task<(bool isNewUser, bool isNewDevice)>

A task representing the asynchronous operation. The task result contains a boolean indicating if the user is new and a boolean indicating if the device is new.

Exceptions

Exception

Thrown when email or phone number is not provided.