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
ThirdwebClientThe Thirdweb client instance.
email
stringThe email address for Email OTP authentication.
phoneNumber
stringThe phone number for Phone OTP authentication.
authProvider
AuthProviderThe authentication provider to use.
storageDirectoryPath
stringThe path to the storage directory.
siweSigner
IThirdwebWalletThe 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()
Returns a list of linked accounts to the current wallet.
public override Task<List<LinkedAccount>> GetLinkedAccounts()
Returns
- Task<List<LinkedAccount>>
A list of LinkedAccount objects.
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(IThirdwebWallet, string, bool?, Action<string>, string, IThirdwebBrowser, BigInteger?, string, string)
Links a new account (auth method) to the current wallet. The current wallet must be connected and the wallet being linked must not be fully connected ie created.
public override Task<List<LinkedAccount>> LinkAccount(IThirdwebWallet 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
IThirdwebWalletThe wallet to link.
otp
stringThe OTP code if the wallet to link is an email or phone wallet.
isMobile
bool?Set to true if linking OAuth on mobile.
browserOpenAction
Action<string>The action to open the browser if linking OAuth.
mobileRedirectScheme
stringThe redirect scheme if linking OAuth on mobile.
browser
IThirdwebBrowserThe browser to use if linking OAuth.
chainId
BigInteger?The chain ID if linking an external wallet (SIWE).
jwt
stringThe JWT token if linking custom JWT auth.
payload
stringThe login payload if linking custom AuthEndpoint auth.
Returns
- Task<List<LinkedAccount>>
A list of LinkedAccount objects.
LoginWithAuthEndpoint(string, string)
Logs in with an authentication endpoint.
public Task<string> LoginWithAuthEndpoint(string payload, string encryptionKey)
Parameters
payload
stringThe payload to use for authentication.
encryptionKey
stringThe 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
LoginWithJWT(string, string)
Logs in with a JWT.
public Task<string> LoginWithJWT(string jwt, string encryptionKey)
Parameters
Returns
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
boolIndicates if the login is from a mobile device.
browserOpenAction
Action<string>The action to open the browser.
mobileRedirectScheme
stringThe mobile redirect scheme.
browser
IThirdwebBrowserThe browser instance.
cancellationToken
CancellationTokenThe 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
stringThe 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
BigIntegerThe chain ID to use for signing the SIWE payload
Returns
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.