Class EcosystemWallet
- Namespace
- Thirdweb
- Assembly
- Thirdweb.dll
Enclave based secure cross ecosystem wallet.
public class EcosystemWallet : IThirdwebWallet
- Inheritance
-
EcosystemWallet
- Implements
- Derived
- Inherited Members
- Extension Methods
Properties
AccountType
Gets the account type of the wallet.
public ThirdwebAccountType AccountType { get; }
Property Value
Client
Gets the Thirdweb client associated with the wallet.
public ThirdwebClient Client { get; }
Property Value
WalletId
String identifier for the wallet to be used in analytics.
public virtual string WalletId { get; }
Property Value
Methods
Create(ThirdwebClient, string, string, string, string, AuthProvider, string, IThirdwebWallet, string, string, ExecutionMode)
Creates a new instance of the EcosystemWallet class.
public static Task<EcosystemWallet> Create(ThirdwebClient client, string ecosystemId = null, string ecosystemPartnerId = null, string email = null, string phoneNumber = null, AuthProvider authProvider = AuthProvider.Default, string storageDirectoryPath = null, IThirdwebWallet siweSigner = null, string walletSecret = null, string twAuthTokenOverride = null, ExecutionMode executionMode = ExecutionMode.EOA)
Parameters
clientThirdwebClientThe Thirdweb client instance.
ecosystemIdstringYour ecosystem ID (see thirdweb dashboard e.g. ecosystem.the-bonfire).
ecosystemPartnerIdstringYour ecosystem partner ID (required if you are integrating someone else's ecosystem).
emailstringThe email address for Email OTP authentication.
phoneNumberstringThe phone number for Phone OTP authentication.
authProviderAuthProviderThe authentication provider to use.
storageDirectoryPathstringThe path to the storage directory.
siweSignerIThirdwebWalletThe SIWE signer wallet for SIWE authentication.
walletSecretstringThe wallet secret for Backend authentication.
twAuthTokenOverridestringThe auth token to use for the session. This will automatically connect using a raw thirdweb auth token.
executionModeExecutionModeThe execution mode for the wallet. EOA represents traditional direct calls, EIP7702 represents upgraded account self sponsored calls, and EIP7702Sponsored represents upgraded account calls with managed/sponsored execution.
Returns
- Task<EcosystemWallet>
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.
CreateSessionKey(BigInteger, string, long, bool, List<CallSpec>, List<TransferSpec>, byte[])
Creates a session key for the user wallet. This is only supported for EIP7702 and EIP7702Sponsored execution modes.
public Task<ThirdwebTransactionReceipt> CreateSessionKey(BigInteger chainId, string signerAddress, long durationInSeconds, bool grantFullPermissions = true, List<CallSpec> callPolicies = null, List<TransferSpec> transferPolicies = null, byte[] uid = null)
Parameters
chainIdBigIntegerThe chain ID for the session key.
signerAddressstringThe address of the signer for the session key.
durationInSecondslongDuration in seconds for which the session key will be valid.
grantFullPermissionsboolWhether to grant full permissions to the session key. If false, only the specified call and transfer policies will be applied.
callPoliciesList<CallSpec>List of call policies to apply to the session key. If null, no call policies will be applied.
transferPoliciesList<TransferSpec>List of transfer policies to apply to the session key. If null, no transfer policies will be applied.
uidbyte[]A unique identifier for the session key. If null, a new GUID will be generated.
Returns
- Task<ThirdwebTransactionReceipt>
A task that represents the asynchronous operation. The task result contains the transaction receipt for the session key creation.
Exceptions
- InvalidOperationException
Thrown when the execution mode is not EIP7702 or EIP7702Sponsored.
- ArgumentException
Thrown when the signer address is null or empty, or when the duration is less than or equal to zero.
Disconnect()
Disconnects the wallet (if using InAppWallet, clears session)
public Task Disconnect()
Returns
ExecuteTransaction(ThirdwebTransactionInput)
Sends a transaction and waits for its receipt.
public Task<ThirdwebTransactionReceipt> ExecuteTransaction(ThirdwebTransactionInput transactionInput)
Parameters
transactionInputThirdwebTransactionInput
Returns
- Task<ThirdwebTransactionReceipt>
The transaction receipt.
GenerateExternalLoginLink(string)
Returns a link that can be used to transfer the .NET wallet session to a thirdweb powered React website for seamless integration.
public string GenerateExternalLoginLink(string redirectUrl)
Parameters
redirectUrlstringThe URL of your thirdweb-powered website.
Returns
- string
The URL to redirect the user to.
Exceptions
- InvalidOperationException
Thrown when no connected session is found
GetAddress()
Gets the address of the wallet.
public Task<string> GetAddress()
Returns
GetCallPoliciesForSigner(BigInteger, string)
Gets the call policies for a specific signer on the EIP7702 account.
public Task<List<CallSpec>> GetCallPoliciesForSigner(BigInteger chainId, string signerAddress)
Parameters
chainIdBigIntegerThe chain ID of the EIP7702 account.
signerAddressstringThe address of the signer to get call policies for.
Returns
- Task<List<CallSpec>>
A task that represents the asynchronous operation. The task result contains a list of call policies for the signer.
Exceptions
- InvalidOperationException
Thrown when the execution mode is not EIP7702 or EIP7702Sponsored.
- ArgumentException
Thrown when the signer address is null or empty.
GetEcosystemDetails()
Returns Ecosystem metadata (set in thirdweb Dashboard)
public Task<EcosystemWallet.EcosystemDetails> GetEcosystemDetails()
Returns
- Task<EcosystemWallet.EcosystemDetails>
Instance of EcosystemWallet.EcosystemDetails containing metadata
Exceptions
- InvalidOperationException
Thrown when called on an InAppWallet
GetEmail()
[Obsolete("Use GetUserDetails instead.")]
public string GetEmail()
Returns
GetLinkedAccounts()
Returns a list of linked accounts to the current wallet.
public Task<List<LinkedAccount>> GetLinkedAccounts()
Returns
- Task<List<LinkedAccount>>
A list of LinkedAccount objects.
GetPhoneNumber()
[Obsolete("Use GetUserDetails instead.")]
public string GetPhoneNumber()
Returns
GetSessionExpirationForSigner(BigInteger, string)
Gets the session expiration timestamp for a specific signer on the EIP7702 account.
public Task<BigInteger> GetSessionExpirationForSigner(BigInteger chainId, string signerAddress)
Parameters
chainIdBigIntegerThe chain ID of the EIP7702 account.
signerAddressstringThe address of the signer to get session expiration for.
Returns
- Task<BigInteger>
A task that represents the asynchronous operation. The task result contains the session expiration timestamp.
Exceptions
- InvalidOperationException
Thrown when the execution mode is not EIP7702 or EIP7702Sponsored.
- ArgumentException
Thrown when the signer address is null or empty.
GetSessionStateForSigner(BigInteger, string)
Gets the complete session state for a specific signer on the EIP7702 account, including remaining limits and usage information.
public Task<SessionState> GetSessionStateForSigner(BigInteger chainId, string signerAddress)
Parameters
chainIdBigIntegerThe chain ID of the EIP7702 account.
signerAddressstringThe address of the signer to get session state for.
Returns
- Task<SessionState>
A task that represents the asynchronous operation. The task result contains the session state with transfer value limits, call value limits, and call parameter limits.
Exceptions
- InvalidOperationException
Thrown when the execution mode is not EIP7702 or EIP7702Sponsored.
- ArgumentException
Thrown when the signer address is null or empty.
GetTransferPoliciesForSigner(BigInteger, string)
Gets the transfer policies for a specific signer on the EIP7702 account.
public Task<List<TransferSpec>> GetTransferPoliciesForSigner(BigInteger chainId, string signerAddress)
Parameters
chainIdBigIntegerThe chain ID of the EIP7702 account.
signerAddressstringThe address of the signer to get transfer policies for.
Returns
- Task<List<TransferSpec>>
A task that represents the asynchronous operation. The task result contains a list of transfer policies for the signer.
Exceptions
- InvalidOperationException
Thrown when the execution mode is not EIP7702 or EIP7702Sponsored.
- ArgumentException
Thrown when the signer address is null or empty.
GetUserAuthDetails()
Gets the user auth details from the corresponding auth provider. For linked account details use GetUserDetails or GetLinkedAccounts.
public JObject GetUserAuthDetails()
Returns
- JObject
The user auth details as a JObject
GetUserDetails()
Gets the user details from the enclave wallet. For auth provider specific details use GetUserAuthDetails.
public Task<EcosystemWallet.UserStatusResponse> GetUserDetails()
Returns
- Task<EcosystemWallet.UserStatusResponse>
A task that represents the asynchronous operation. The task result contains the user details.
IsConnected()
Checks if the wallet is connected.
public Task<bool> IsConnected()
Returns
LinkAccount(IThirdwebWallet, string, bool?, Action<string>, string, IThirdwebBrowser, BigInteger?, string, 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 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, string defaultSessionIdOverride = null)
Parameters
walletToLinkIThirdwebWalletThe wallet to link.
otpstringThe OTP code if the wallet to link is an email or phone wallet.
isMobilebool?Set to true if linking OAuth on mobile.
browserOpenActionAction<string>The action to open the browser if linking OAuth.
mobileRedirectSchemestringThe redirect scheme if linking OAuth on mobile.
browserIThirdwebBrowserThe browser to use if linking OAuth.
chainIdBigInteger?The chain ID if linking an external wallet (SIWE).
jwtstringThe JWT token if linking custom JWT auth.
payloadstringThe login payload if linking custom AuthEndpoint auth.
defaultSessionIdOverridestringThe default session ID override if linking Guest auth.
Returns
- Task<List<LinkedAccount>>
A list of LinkedAccount objects.
LoginWithAuthEndpoint(string)
public Task<string> LoginWithAuthEndpoint(string payload)
Parameters
payloadstring
Returns
LoginWithBackend()
public Task<string> LoginWithBackend()
Returns
LoginWithGuest(string)
public Task<string> LoginWithGuest(string defaultSessionIdOverride = null)
Parameters
defaultSessionIdOverridestring
Returns
LoginWithJWT(string)
public Task<string> LoginWithJWT(string jwt)
Parameters
jwtstring
Returns
LoginWithOauth(bool, Action<string>, string, IThirdwebBrowser, CancellationToken)
public Task<string> LoginWithOauth(bool isMobile, Action<string> browserOpenAction, string mobileRedirectScheme = "thirdweb://", IThirdwebBrowser browser = null, CancellationToken cancellationToken = default)
Parameters
isMobileboolbrowserOpenActionAction<string>mobileRedirectSchemestringbrowserIThirdwebBrowsercancellationTokenCancellationToken
Returns
LoginWithOtp(string)
public Task<string> LoginWithOtp(string otp)
Parameters
otpstring
Returns
LoginWithSiwe(BigInteger)
public Task<string> LoginWithSiwe(BigInteger chainId)
Parameters
chainIdBigInteger
Returns
PersonalSign(byte[])
Signs a raw message using personal signing.
public Task<string> PersonalSign(byte[] rawMessage)
Parameters
rawMessagebyte[]The raw message to sign.
Returns
PersonalSign(string)
Signs a message using personal signing.
public Task<string> PersonalSign(string message)
Parameters
messagestringThe message to sign.
Returns
SendOTP()
public Task SendOTP()
Returns
SendTransaction(ThirdwebTransactionInput)
Sends a transaction.
public Task<string> SendTransaction(ThirdwebTransactionInput transaction)
Parameters
transactionThirdwebTransactionInputThe transaction to send.
Returns
SignAuthorization(BigInteger, string, bool)
Signs an EIP-7702 authorization to invoke contract functions to an externally owned account.
public Task<EIP7702Authorization> SignAuthorization(BigInteger chainId, string contractAddress, bool willSelfExecute)
Parameters
chainIdBigIntegerThe chain ID of the contract.
contractAddressstringThe address of the contract.
willSelfExecuteboolSet to true if the wallet will also be the executor of the transaction, otherwise false.
Returns
- Task<EIP7702Authorization>
The signed authorization as an EIP7702Authorization that can be used with AuthorizationList.
SignTransaction(ThirdwebTransactionInput)
Signs a transaction.
public Task<string> SignTransaction(ThirdwebTransactionInput transaction)
Parameters
transactionThirdwebTransactionInputThe transaction to sign.
Returns
SignTypedDataV4(string)
Signs typed data (version 4).
public Task<string> SignTypedDataV4(string json)
Parameters
jsonstringThe JSON representation of the typed data.
Returns
SignTypedDataV4<T, TDomain>(T, TypedData<TDomain>)
Signs typed data (version 4).
public Task<string> SignTypedDataV4<T, TDomain>(T data, TypedData<TDomain> typedData) where TDomain : IDomain
Parameters
dataTThe data to sign.
typedDataTypedData<TDomain>The typed data.
Returns
Type Parameters
TThe type of the data.
TDomainThe type of the domain.
SignerHasFullPermissions(BigInteger, string)
Checks if the signer has full permissions on the EIP7702 account.
public Task<bool> SignerHasFullPermissions(BigInteger chainId, string signerAddress)
Parameters
chainIdBigIntegerThe chain ID of the EIP7702 account.
signerAddressstringThe address of the signer to check permissions for.
Returns
- Task<bool>
A task that represents the asynchronous operation. The task result contains a boolean indicating whether the signer has full permissions.
Exceptions
- InvalidOperationException
Thrown when the execution mode is not EIP7702 or EIP7702Sponsored.
- ArgumentException
Thrown when the signer address is null or empty.
SwitchNetwork(BigInteger)
Attempts to set the active network to the specified chain ID.
public Task SwitchNetwork(BigInteger chainId)
Parameters
chainIdBigIntegerThe chain ID to switch to.
Returns
UnlinkAccount(LinkedAccount)
Unlinks an account (auth method) from the current wallet.
public Task<List<LinkedAccount>> UnlinkAccount(LinkedAccount accountToUnlink)
Parameters
accountToUnlinkLinkedAccountThe linked account to unlink. Same type returned by GetLinkedAccounts().