From d19304d9e0216f21501d35724179ae73422f717a Mon Sep 17 00:00:00 2001
From: 0xFirekeeper <0xFirekeeper@gmail.com>
Date: Tue, 9 Sep 2025 03:56:08 +0700
Subject: [PATCH 01/29] Add social OAuth endpoint and update payments API
Introduces a new /auth/social endpoint for OAuth flows, deprecates the old OAuth method, and updates documentation accordingly. Refactors payments API: renames and restructures payment creation, completion, and history endpoints, and moves token swap functionality to a new bridge/swap endpoint. Expands wallet token retrieval with new filtering and sorting options.
---
Thirdweb/Thirdweb.Api/GeneratedClient.cs | 1633 ++++++++++++++---
.../EcosystemWallet/EcosystemWallet.cs | 27 +-
.../EmbeddedWallet.Authentication/AWS.cs | 300 ---
.../Server.Types.cs | 4 +-
.../EmbeddedWallet.Authentication/Server.cs | 52 +-
.../EmbeddedWallet.Cryptography.cs | 128 --
.../EmbeddedWallet.Encryption/IvGenerator.cs | 64 -
.../EmbeddedWallet.Encryption/Secrets.cs | 470 -----
.../EmbeddedWallet/EmbeddedWallet.Misc.cs | 73 -
.../EmbeddedWallet/EmbeddedWallet.OAuth.cs | 4 +-
.../EmbeddedWallet/EmbeddedWallet.cs | 11 -
11 files changed, 1362 insertions(+), 1404 deletions(-)
delete mode 100644 Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet.Authentication/AWS.cs
delete mode 100644 Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet.Encryption/EmbeddedWallet.Cryptography.cs
delete mode 100644 Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet.Encryption/IvGenerator.cs
delete mode 100644 Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet.Encryption/Secrets.cs
diff --git a/Thirdweb/Thirdweb.Api/GeneratedClient.cs b/Thirdweb/Thirdweb.Api/GeneratedClient.cs
index b8c1579e..bea26a70 100644
--- a/Thirdweb/Thirdweb.Api/GeneratedClient.cs
+++ b/Thirdweb/Thirdweb.Api/GeneratedClient.cs
@@ -81,15 +81,20 @@ public string BaseUrl
/// **Supported Methods:**
/// - **SMS** - Send verification code to phone number
/// - **Email** - Send verification code to email address
- /// - **OAuth** - Generate redirect link (Google, Apple, Facebook, Discord, GitHub, X, Coinbase, Farcaster, Telegram, LINE, Twitch, Steam)
+ /// - **OAuth** - ⚠️ **DEPRECATED**: Use `/auth/social` instead for OAuth flows
/// - **Passkey** - Generate WebAuthn challenge for biometric authentication
/// - **SIWE** - Generate Sign-In with Ethereum payload
///
+ /// **OAuth Migration:**
+ /// The OAuth method in this endpoint is deprecated. Please use the new `/auth/social` endpoint instead:
+ /// - **Old**: `POST /auth/initiate` with `{"method": "oauth", "provider": "google", "redirectUrl": "..."}`
+ /// - **New**: `GET /auth/social?provider=google&redirectUrl=...`
+ ///
/// **Flow:**
/// 1. Choose your authentication method
/// 2. Provide method-specific parameters
/// 3. Receive challenge data to complete authentication
- /// 4. Use the `/complete` endpoint to finish the process
+ /// 4. Use the /complete endpoint to finish the process
///
/// NOTE: for custom authentication (JWT, auth-payload) and for guest authentication, you can skip this step and use the `/complete` endpoint directly.
///
@@ -112,15 +117,20 @@ public virtual System.Threading.Tasks.Task InitiateAuthenticationAsync
/// **Supported Methods:**
/// - **SMS** - Send verification code to phone number
/// - **Email** - Send verification code to email address
- /// - **OAuth** - Generate redirect link (Google, Apple, Facebook, Discord, GitHub, X, Coinbase, Farcaster, Telegram, LINE, Twitch, Steam)
+ /// - **OAuth** - ⚠️ **DEPRECATED**: Use `/auth/social` instead for OAuth flows
/// - **Passkey** - Generate WebAuthn challenge for biometric authentication
/// - **SIWE** - Generate Sign-In with Ethereum payload
///
+ /// **OAuth Migration:**
+ /// The OAuth method in this endpoint is deprecated. Please use the new `/auth/social` endpoint instead:
+ /// - **Old**: `POST /auth/initiate` with `{"method": "oauth", "provider": "google", "redirectUrl": "..."}`
+ /// - **New**: `GET /auth/social?provider=google&redirectUrl=...`
+ ///
/// **Flow:**
/// 1. Choose your authentication method
/// 2. Provide method-specific parameters
/// 3. Receive challenge data to complete authentication
- /// 4. Use the `/complete` endpoint to finish the process
+ /// 4. Use the /complete endpoint to finish the process
///
/// NOTE: for custom authentication (JWT, auth-payload) and for guest authentication, you can skip this step and use the `/complete` endpoint directly.
///
@@ -231,6 +241,22 @@ public virtual async System.Threading.Tasks.Task InitiateAuthenticatio
/// - `type` - The authentication method used
/// - `walletAddress` - Your new or existing wallet address
///
+ /// **Next step - Verify your token:**
+ /// ```javascript
+ /// // Verify the token and get complete wallet details (server-side)
+ /// fetch('/v1/wallets/me', {
+ /// headers: {
+ /// 'Authorization': 'Bearer ' + token,
+ /// 'x-secret-key': 'your-secret-key'
+ /// }
+ /// })
+ /// .then(response => response.json())
+ /// .then(data => {
+ /// console.log('Wallet verified:', data.result.address);
+ /// console.log('Auth profiles:', data.result.profiles);
+ /// });
+ /// ```
+ ///
/// **Authentication:** Requires `x-client-id` header for frontend usage or `x-secret-key` for backend usage.
///
/// Authentication completed successfully. You now have wallet access.
@@ -260,6 +286,22 @@ public virtual System.Threading.Tasks.Task CompleteAuthenticationAsyn
/// - `type` - The authentication method used
/// - `walletAddress` - Your new or existing wallet address
///
+ /// **Next step - Verify your token:**
+ /// ```javascript
+ /// // Verify the token and get complete wallet details (server-side)
+ /// fetch('/v1/wallets/me', {
+ /// headers: {
+ /// 'Authorization': 'Bearer ' + token,
+ /// 'x-secret-key': 'your-secret-key'
+ /// }
+ /// })
+ /// .then(response => response.json())
+ /// .then(data => {
+ /// console.log('Wallet verified:', data.result.address);
+ /// console.log('Auth profiles:', data.result.profiles);
+ /// });
+ /// ```
+ ///
/// **Authentication:** Requires `x-client-id` header for frontend usage or `x-secret-key` for backend usage.
///
/// Authentication completed successfully. You now have wallet access.
@@ -348,6 +390,236 @@ public virtual async System.Threading.Tasks.Task CompleteAuthenticati
}
}
+ ///
+ /// Social Auth
+ ///
+ ///
+ /// Complete OAuth authentication with social providers in a single step. Unlike other auth methods that require separate initiate/complete calls, OAuth is handled entirely through redirects.
+ ///
+ /// **OAuth Flow (Self-Contained):**
+ /// 1. Redirect your user to this endpoint with provider and redirectUrl
+ /// 2. User completes OAuth flow with the provider
+ /// 3. User is redirected back to your redirectUrl with wallet credentials
+ ///
+ /// **Why OAuth is different:** OAuth providers handle the challenge/response flow externally, so no separate `/complete` step is needed.
+ ///
+ /// **Example:**
+ /// Redirect user to: `GET /v1/auth/social?provider=google&redirectUrl=https://myapp.com/auth/callback`
+ ///
+ /// **Callback Handling:**
+ /// After OAuth completion, user arrives at your redirectUrl with an `authResult` query parameter:
+ /// ```
+ /// https://myapp.com/auth/callback?authResult=%7B%22storedToken%22%3A%7B%22authDetails%22%3A%7B...%7D%2C%22cookieString%22%3A%22eyJ...%22%7D%7D
+ /// ```
+ ///
+ /// **Extract JWT token in your callback:**
+ /// ```javascript
+ /// // Parse the authResult from URL
+ /// const urlParams = new URLSearchParams(window.location.search);
+ /// const authResultString = urlParams.get('authResult');
+ /// const authResult = JSON.parse(authResultString!);
+ ///
+ /// // Extract the JWT token
+ /// const token = authResult.storedToken.cookieString;
+ /// ```
+ ///
+ /// **Verify and use the JWT token:**
+ /// ```javascript
+ /// // Use the JWT token for authenticated requests
+ /// fetch('/v1/wallets/me', {
+ /// headers: {
+ /// 'Authorization': 'Bearer ' + token,
+ /// 'x-secret-key': 'your-secret-key'
+ /// }
+ /// })
+ /// .then(response => response.json())
+ /// .then(data => {
+ /// console.log('Wallet verified:', data.result.address);
+ /// console.log('Auth profiles:', data.result.profiles);
+ /// });
+ /// ```
+ ///
+ /// **Authentication Options:**
+ /// Choose one of two ways to provide your client credentials:
+ ///
+ /// **Option 1: Query Parameter (Recommended for OAuth flows)**
+ /// ```
+ /// GET /v1/auth/social?provider=google&redirectUrl=https://myapp.com/callback&clientId=your_client_id
+ /// ```
+ ///
+ /// **Option 2: Header (Alternative)**
+ /// ```
+ /// GET /v1/auth/social?provider=google&redirectUrl=https://myapp.com/callback
+ /// Headers: x-client-id: your_client_id
+ /// ```
+ ///
+ /// The OAuth provider to use
+ /// URL to redirect the user to after OAuth completion
+ /// Client ID (alternative to x-client-id header for standard OAuth flows)
+ /// A server side error occurred.
+ public virtual System.Threading.Tasks.Task SocialAuthenticationAsync(Provider provider, System.Uri redirectUrl, string clientId)
+ {
+ return SocialAuthenticationAsync(provider, redirectUrl, clientId, System.Threading.CancellationToken.None);
+ }
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Social Auth
+ ///
+ ///
+ /// Complete OAuth authentication with social providers in a single step. Unlike other auth methods that require separate initiate/complete calls, OAuth is handled entirely through redirects.
+ ///
+ /// **OAuth Flow (Self-Contained):**
+ /// 1. Redirect your user to this endpoint with provider and redirectUrl
+ /// 2. User completes OAuth flow with the provider
+ /// 3. User is redirected back to your redirectUrl with wallet credentials
+ ///
+ /// **Why OAuth is different:** OAuth providers handle the challenge/response flow externally, so no separate `/complete` step is needed.
+ ///
+ /// **Example:**
+ /// Redirect user to: `GET /v1/auth/social?provider=google&redirectUrl=https://myapp.com/auth/callback`
+ ///
+ /// **Callback Handling:**
+ /// After OAuth completion, user arrives at your redirectUrl with an `authResult` query parameter:
+ /// ```
+ /// https://myapp.com/auth/callback?authResult=%7B%22storedToken%22%3A%7B%22authDetails%22%3A%7B...%7D%2C%22cookieString%22%3A%22eyJ...%22%7D%7D
+ /// ```
+ ///
+ /// **Extract JWT token in your callback:**
+ /// ```javascript
+ /// // Parse the authResult from URL
+ /// const urlParams = new URLSearchParams(window.location.search);
+ /// const authResultString = urlParams.get('authResult');
+ /// const authResult = JSON.parse(authResultString!);
+ ///
+ /// // Extract the JWT token
+ /// const token = authResult.storedToken.cookieString;
+ /// ```
+ ///
+ /// **Verify and use the JWT token:**
+ /// ```javascript
+ /// // Use the JWT token for authenticated requests
+ /// fetch('/v1/wallets/me', {
+ /// headers: {
+ /// 'Authorization': 'Bearer ' + token,
+ /// 'x-secret-key': 'your-secret-key'
+ /// }
+ /// })
+ /// .then(response => response.json())
+ /// .then(data => {
+ /// console.log('Wallet verified:', data.result.address);
+ /// console.log('Auth profiles:', data.result.profiles);
+ /// });
+ /// ```
+ ///
+ /// **Authentication Options:**
+ /// Choose one of two ways to provide your client credentials:
+ ///
+ /// **Option 1: Query Parameter (Recommended for OAuth flows)**
+ /// ```
+ /// GET /v1/auth/social?provider=google&redirectUrl=https://myapp.com/callback&clientId=your_client_id
+ /// ```
+ ///
+ /// **Option 2: Header (Alternative)**
+ /// ```
+ /// GET /v1/auth/social?provider=google&redirectUrl=https://myapp.com/callback
+ /// Headers: x-client-id: your_client_id
+ /// ```
+ ///
+ /// The OAuth provider to use
+ /// URL to redirect the user to after OAuth completion
+ /// Client ID (alternative to x-client-id header for standard OAuth flows)
+ /// A server side error occurred.
+ public virtual async System.Threading.Tasks.Task SocialAuthenticationAsync(Provider provider, System.Uri redirectUrl, string clientId, System.Threading.CancellationToken cancellationToken)
+ {
+ if (provider == null)
+ throw new System.ArgumentNullException("provider");
+
+ if (redirectUrl == null)
+ throw new System.ArgumentNullException("redirectUrl");
+
+ var client_ = _httpClient;
+ var disposeClient_ = false;
+ try
+ {
+ using (var request_ = new System.Net.Http.HttpRequestMessage())
+ {
+ request_.Method = new System.Net.Http.HttpMethod("GET");
+
+ var urlBuilder_ = new System.Text.StringBuilder();
+ if (!string.IsNullOrEmpty(_baseUrl)) urlBuilder_.Append(_baseUrl);
+ // Operation Path: "v1/auth/social"
+ urlBuilder_.Append("v1/auth/social");
+ urlBuilder_.Append('?');
+ urlBuilder_.Append(System.Uri.EscapeDataString("provider")).Append('=').Append(System.Uri.EscapeDataString(ConvertToString(provider, System.Globalization.CultureInfo.InvariantCulture))).Append('&');
+ urlBuilder_.Append(System.Uri.EscapeDataString("redirectUrl")).Append('=').Append(System.Uri.EscapeDataString(ConvertToString(redirectUrl, System.Globalization.CultureInfo.InvariantCulture))).Append('&');
+ if (clientId != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("clientId")).Append('=').Append(System.Uri.EscapeDataString(ConvertToString(clientId, System.Globalization.CultureInfo.InvariantCulture))).Append('&');
+ }
+ urlBuilder_.Length--;
+
+ PrepareRequest(client_, request_, urlBuilder_);
+
+ var url_ = urlBuilder_.ToString();
+ request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
+
+ PrepareRequest(client_, request_, url_);
+
+ var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ var disposeResponse_ = true;
+ try
+ {
+ var headers_ = new System.Collections.Generic.Dictionary>();
+ foreach (var item_ in response_.Headers)
+ headers_[item_.Key] = item_.Value;
+ if (response_.Content != null && response_.Content.Headers != null)
+ {
+ foreach (var item_ in response_.Content.Headers)
+ headers_[item_.Key] = item_.Value;
+ }
+
+ ProcessResponse(client_, response_);
+
+ var status_ = (int)response_.StatusCode;
+ if (status_ == 302)
+ {
+ string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ThirdwebApiException("Redirects to OAuth provider for authentication", status_, responseText_, headers_, null);
+ }
+ else
+ if (status_ == 400)
+ {
+ string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ThirdwebApiException("Invalid request parameters", status_, responseText_, headers_, null);
+ }
+ else
+
+ if (status_ == 200 || status_ == 204)
+ {
+
+ return;
+ }
+ else
+ {
+ var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ThirdwebApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
+ }
+ }
+ finally
+ {
+ if (disposeResponse_)
+ response_.Dispose();
+ }
+ }
+ }
+ finally
+ {
+ if (disposeClient_)
+ client_.Dispose();
+ }
+ }
+
///
/// Get My Wallet
///
@@ -1294,7 +1566,7 @@ public virtual async System.Threading.Tasks.Task GetWalletTransaction
/// Get Tokens
///
///
- /// Retrieves token balances for a specific wallet address across one or more blockchain networks. This endpoint provides comprehensive token data including ERC-20 tokens with their balances, metadata, and price information. Results can be filtered by chain and paginated to meet specific requirements.
+ /// Retrieves token balances for a specific wallet address across one or more blockchain networks. This endpoint provides comprehensive token data including ERC-20 tokens with their balances, metadata, and price information. Results can be filtered by chain, sorted by balance or USD value, and customized to include/exclude spam tokens, native tokens, and tokens without price data. Supports pagination and metadata resolution options.
///
/// **Authentication**: Pass `x-client-id` header for frontend usage from allowlisted origins or `x-secret-key` for backend usage.
///
@@ -1303,11 +1575,18 @@ public virtual async System.Threading.Tasks.Task GetWalletTransaction
/// Token addresses to filter by. If provided, only tokens with these addresses will be returned.
/// The number of tokens to return per chain (default: 20, max: 500).
/// The page number for pagination (default: 1, max: 20).
- /// Wallet tokens retrieved successfully. Returns token data with metadata including pagination information and chain details. Includes token balances, metadata, and price information when available.
+ /// Whether to include token metadata (default: true).
+ /// Whether to resolve metadata links to fetch additional token information (default: true).
+ /// Whether to include tokens marked as spam (default: false).
+ /// Whether to include native tokens (e.g., ETH, MATIC) in the results (default: true).
+ /// Field to sort tokens by: 'balance' for token balance, 'token_address' for token address, 'token_price' for token price, 'usd_value' for USD value (default: usd_value).
+ /// Sort order: 'asc' for ascending, 'desc' for descending (default: desc).
+ /// Whether to include tokens without price data (default: true).
+ /// Wallet tokens retrieved successfully. Returns token data with metadata including pagination information and chain details. Includes token balances, metadata, and price information when available. Results are sorted by the specified criteria (default: USD value descending) and filtered according to the provided parameters.
/// A server side error occurred.
- public virtual System.Threading.Tasks.Task GetWalletTokensAsync(string address, System.Collections.Generic.IEnumerable chainId, System.Collections.Generic.IEnumerable tokenAddresses, int? limit, int? page)
+ public virtual System.Threading.Tasks.Task GetWalletTokensAsync(string address, System.Collections.Generic.IEnumerable chainId, System.Collections.Generic.IEnumerable tokenAddresses, int? limit, int? page, Metadata? metadata, ResolveMetadataLinks? resolveMetadataLinks, IncludeSpam? includeSpam, IncludeNative? includeNative, SortBy? sortBy, SortOrder2? sortOrder, IncludeWithoutPrice? includeWithoutPrice)
{
- return GetWalletTokensAsync(address, chainId, tokenAddresses, limit, page, System.Threading.CancellationToken.None);
+ return GetWalletTokensAsync(address, chainId, tokenAddresses, limit, page, metadata, resolveMetadataLinks, includeSpam, includeNative, sortBy, sortOrder, includeWithoutPrice, System.Threading.CancellationToken.None);
}
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
@@ -1315,7 +1594,7 @@ public virtual System.Threading.Tasks.Task GetWalletTokensAsync(stri
/// Get Tokens
///
///
- /// Retrieves token balances for a specific wallet address across one or more blockchain networks. This endpoint provides comprehensive token data including ERC-20 tokens with their balances, metadata, and price information. Results can be filtered by chain and paginated to meet specific requirements.
+ /// Retrieves token balances for a specific wallet address across one or more blockchain networks. This endpoint provides comprehensive token data including ERC-20 tokens with their balances, metadata, and price information. Results can be filtered by chain, sorted by balance or USD value, and customized to include/exclude spam tokens, native tokens, and tokens without price data. Supports pagination and metadata resolution options.
///
/// **Authentication**: Pass `x-client-id` header for frontend usage from allowlisted origins or `x-secret-key` for backend usage.
///
@@ -1324,9 +1603,16 @@ public virtual System.Threading.Tasks.Task GetWalletTokensAsync(stri
/// Token addresses to filter by. If provided, only tokens with these addresses will be returned.
/// The number of tokens to return per chain (default: 20, max: 500).
/// The page number for pagination (default: 1, max: 20).
- /// Wallet tokens retrieved successfully. Returns token data with metadata including pagination information and chain details. Includes token balances, metadata, and price information when available.
+ /// Whether to include token metadata (default: true).
+ /// Whether to resolve metadata links to fetch additional token information (default: true).
+ /// Whether to include tokens marked as spam (default: false).
+ /// Whether to include native tokens (e.g., ETH, MATIC) in the results (default: true).
+ /// Field to sort tokens by: 'balance' for token balance, 'token_address' for token address, 'token_price' for token price, 'usd_value' for USD value (default: usd_value).
+ /// Sort order: 'asc' for ascending, 'desc' for descending (default: desc).
+ /// Whether to include tokens without price data (default: true).
+ /// Wallet tokens retrieved successfully. Returns token data with metadata including pagination information and chain details. Includes token balances, metadata, and price information when available. Results are sorted by the specified criteria (default: USD value descending) and filtered according to the provided parameters.
/// A server side error occurred.
- public virtual async System.Threading.Tasks.Task GetWalletTokensAsync(string address, System.Collections.Generic.IEnumerable chainId, System.Collections.Generic.IEnumerable tokenAddresses, int? limit, int? page, System.Threading.CancellationToken cancellationToken)
+ public virtual async System.Threading.Tasks.Task GetWalletTokensAsync(string address, System.Collections.Generic.IEnumerable chainId, System.Collections.Generic.IEnumerable tokenAddresses, int? limit, int? page, Metadata? metadata, ResolveMetadataLinks? resolveMetadataLinks, IncludeSpam? includeSpam, IncludeNative? includeNative, SortBy? sortBy, SortOrder2? sortOrder, IncludeWithoutPrice? includeWithoutPrice, System.Threading.CancellationToken cancellationToken)
{
if (address == null)
throw new System.ArgumentNullException("address");
@@ -1375,6 +1661,34 @@ public virtual async System.Threading.Tasks.Task GetWalletTokensAsyn
{
urlBuilder_.Append(System.Uri.EscapeDataString("page")).Append('=').Append(System.Uri.EscapeDataString(ConvertToString(page, System.Globalization.CultureInfo.InvariantCulture))).Append('&');
}
+ if (metadata != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("metadata")).Append('=').Append(System.Uri.EscapeDataString(ConvertToString(metadata, System.Globalization.CultureInfo.InvariantCulture))).Append('&');
+ }
+ if (resolveMetadataLinks != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("resolveMetadataLinks")).Append('=').Append(System.Uri.EscapeDataString(ConvertToString(resolveMetadataLinks, System.Globalization.CultureInfo.InvariantCulture))).Append('&');
+ }
+ if (includeSpam != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("includeSpam")).Append('=').Append(System.Uri.EscapeDataString(ConvertToString(includeSpam, System.Globalization.CultureInfo.InvariantCulture))).Append('&');
+ }
+ if (includeNative != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("includeNative")).Append('=').Append(System.Uri.EscapeDataString(ConvertToString(includeNative, System.Globalization.CultureInfo.InvariantCulture))).Append('&');
+ }
+ if (sortBy != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("sortBy")).Append('=').Append(System.Uri.EscapeDataString(ConvertToString(sortBy, System.Globalization.CultureInfo.InvariantCulture))).Append('&');
+ }
+ if (sortOrder != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("sortOrder")).Append('=').Append(System.Uri.EscapeDataString(ConvertToString(sortOrder, System.Globalization.CultureInfo.InvariantCulture))).Append('&');
+ }
+ if (includeWithoutPrice != null)
+ {
+ urlBuilder_.Append(System.Uri.EscapeDataString("includeWithoutPrice")).Append('=').Append(System.Uri.EscapeDataString(ConvertToString(includeWithoutPrice, System.Globalization.CultureInfo.InvariantCulture))).Append('&');
+ }
urlBuilder_.Length--;
PrepareRequest(client_, request_, urlBuilder_);
@@ -2495,7 +2809,7 @@ public virtual async System.Threading.Tasks.Task WriteContractAsync(
/// Sort order: 'asc' for ascending, 'desc' for descending
/// Contract transactions retrieved successfully. Returns transaction data with metadata including pagination information. Includes decoded function calls when ABI is available.
/// A server side error occurred.
- public virtual System.Threading.Tasks.Task GetContractTransactionsAsync(int chainId, string address, string filterFromAddress, string filterToAddress, int? filterBlockTimestampGte, int? filterBlockTimestampLte, int? filterBlockNumberGte, int? filterBlockNumberLte, string filterValueGt, string filterFunctionSelector, double? page, double? limit, SortOrder2? sortOrder)
+ public virtual System.Threading.Tasks.Task GetContractTransactionsAsync(int chainId, string address, string filterFromAddress, string filterToAddress, int? filterBlockTimestampGte, int? filterBlockTimestampLte, int? filterBlockNumberGte, int? filterBlockNumberLte, string filterValueGt, string filterFunctionSelector, double? page, double? limit, SortOrder3? sortOrder)
{
return GetContractTransactionsAsync(chainId, address, filterFromAddress, filterToAddress, filterBlockTimestampGte, filterBlockTimestampLte, filterBlockNumberGte, filterBlockNumberLte, filterValueGt, filterFunctionSelector, page, limit, sortOrder, System.Threading.CancellationToken.None);
}
@@ -2524,7 +2838,7 @@ public virtual System.Threading.Tasks.Task GetContractTransactionsAs
/// Sort order: 'asc' for ascending, 'desc' for descending
/// Contract transactions retrieved successfully. Returns transaction data with metadata including pagination information. Includes decoded function calls when ABI is available.
/// A server side error occurred.
- public virtual async System.Threading.Tasks.Task GetContractTransactionsAsync(int chainId, string address, string filterFromAddress, string filterToAddress, int? filterBlockTimestampGte, int? filterBlockTimestampLte, int? filterBlockNumberGte, int? filterBlockNumberLte, string filterValueGt, string filterFunctionSelector, double? page, double? limit, SortOrder2? sortOrder, System.Threading.CancellationToken cancellationToken)
+ public virtual async System.Threading.Tasks.Task GetContractTransactionsAsync(int chainId, string address, string filterFromAddress, string filterToAddress, int? filterBlockTimestampGte, int? filterBlockTimestampLte, int? filterBlockNumberGte, int? filterBlockNumberLte, string filterValueGt, string filterFunctionSelector, double? page, double? limit, SortOrder3? sortOrder, System.Threading.CancellationToken cancellationToken)
{
if (chainId == null)
throw new System.ArgumentNullException("chainId");
@@ -2696,7 +3010,7 @@ public virtual async System.Threading.Tasks.Task GetContractTransact
/// Sort order: 'asc' for ascending, 'desc' for descending
/// Contract events retrieved successfully. Returns event data with metadata including pagination information. Includes decoded event parameters when ABI is available.
/// A server side error occurred.
- public virtual System.Threading.Tasks.Task GetContractEventsAsync(int chainId, string address, string signature, string filterTopic0, string filterTopic1, string filterTopic2, string filterTopic3, int? filterBlockTimestampGte, int? filterBlockTimestampLte, int? filterBlockNumberGte, int? filterBlockNumberLte, double? page, double? limit, SortOrder3? sortOrder)
+ public virtual System.Threading.Tasks.Task GetContractEventsAsync(int chainId, string address, string signature, string filterTopic0, string filterTopic1, string filterTopic2, string filterTopic3, int? filterBlockTimestampGte, int? filterBlockTimestampLte, int? filterBlockNumberGte, int? filterBlockNumberLte, double? page, double? limit, SortOrder4? sortOrder)
{
return GetContractEventsAsync(chainId, address, signature, filterTopic0, filterTopic1, filterTopic2, filterTopic3, filterBlockTimestampGte, filterBlockTimestampLte, filterBlockNumberGte, filterBlockNumberLte, page, limit, sortOrder, System.Threading.CancellationToken.None);
}
@@ -2726,7 +3040,7 @@ public virtual System.Threading.Tasks.Task GetContractEventsAsync(in
/// Sort order: 'asc' for ascending, 'desc' for descending
/// Contract events retrieved successfully. Returns event data with metadata including pagination information. Includes decoded event parameters when ABI is available.
/// A server side error occurred.
- public virtual async System.Threading.Tasks.Task GetContractEventsAsync(int chainId, string address, string signature, string filterTopic0, string filterTopic1, string filterTopic2, string filterTopic3, int? filterBlockTimestampGte, int? filterBlockTimestampLte, int? filterBlockNumberGte, int? filterBlockNumberLte, double? page, double? limit, SortOrder3? sortOrder, System.Threading.CancellationToken cancellationToken)
+ public virtual async System.Threading.Tasks.Task GetContractEventsAsync(int chainId, string address, string signature, string filterTopic0, string filterTopic1, string filterTopic2, string filterTopic3, int? filterBlockTimestampGte, int? filterBlockTimestampLte, int? filterBlockNumberGte, int? filterBlockNumberLte, double? page, double? limit, SortOrder4? sortOrder, System.Threading.CancellationToken cancellationToken)
{
if (chainId == null)
throw new System.ArgumentNullException("chainId");
@@ -3535,32 +3849,32 @@ public virtual async System.Threading.Tasks.Task SendTransactionsAsy
}
///
- /// Swap Tokens
+ /// Create Payment
///
///
- /// Swap one token for another using the optimal route available. You can specify a tokenIn amount (if exact='input') or tokenOut amount (if exact='output'), but not both. The corresponding output or input amount will be returned as the quote.
+ /// Create a payment to be executed. Users can complete the payment via hosted UI (link is returned), a transaction execution referencing the product ID, or embedded widgets with the product ID.
///
- /// **Authentication**: This endpoint requires project authentication and wallet authentication. For backend usage, use `x-secret-key` header. For frontend usage, use `x-client-id` + `Authorization: Bearer <jwt>` headers.
+ /// **Authentication**: This endpoint requires project authentication.
///
- /// Swap completed successfully. Returns the transaction used for the swap.
+ /// Payment created successfully. Returns the ID and link to complete the payment.
/// A server side error occurred.
- public virtual System.Threading.Tasks.Task PaymentsSwapAsync(Body12 body)
+ public virtual System.Threading.Tasks.Task CreatePaymentAsync(Body12 body)
{
- return PaymentsSwapAsync(body, System.Threading.CancellationToken.None);
+ return CreatePaymentAsync(body, System.Threading.CancellationToken.None);
}
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
///
- /// Swap Tokens
+ /// Create Payment
///
///
- /// Swap one token for another using the optimal route available. You can specify a tokenIn amount (if exact='input') or tokenOut amount (if exact='output'), but not both. The corresponding output or input amount will be returned as the quote.
+ /// Create a payment to be executed. Users can complete the payment via hosted UI (link is returned), a transaction execution referencing the product ID, or embedded widgets with the product ID.
///
- /// **Authentication**: This endpoint requires project authentication and wallet authentication. For backend usage, use `x-secret-key` header. For frontend usage, use `x-client-id` + `Authorization: Bearer <jwt>` headers.
+ /// **Authentication**: This endpoint requires project authentication.
///
- /// Swap completed successfully. Returns the transaction used for the swap.
+ /// Payment created successfully. Returns the ID and link to complete the payment.
/// A server side error occurred.
- public virtual async System.Threading.Tasks.Task PaymentsSwapAsync(Body12 body, System.Threading.CancellationToken cancellationToken)
+ public virtual async System.Threading.Tasks.Task CreatePaymentAsync(Body12 body, System.Threading.CancellationToken cancellationToken)
{
var client_ = _httpClient;
var disposeClient_ = false;
@@ -3577,8 +3891,8 @@ public virtual async System.Threading.Tasks.Task PaymentsSwapAsync(B
var urlBuilder_ = new System.Text.StringBuilder();
if (!string.IsNullOrEmpty(_baseUrl)) urlBuilder_.Append(_baseUrl);
- // Operation Path: "v1/payments/swap"
- urlBuilder_.Append("v1/payments/swap");
+ // Operation Path: "v1/payments"
+ urlBuilder_.Append("v1/payments");
PrepareRequest(client_, request_, urlBuilder_);
@@ -3657,33 +3971,36 @@ public virtual async System.Threading.Tasks.Task PaymentsSwapAsync(B
}
///
- /// Create Payment
+ /// Complete Payment
///
///
- /// Create a payment to be executed. Users can complete the payment via hosted UI (link is returned), a transaction execution referencing the product ID, or embedded widgets with the product ID.
+ /// Completes a payment using its default token and amount. If the user does not have sufficient funds in the product's default payment token a 402 status will be returned containing a link and raw quote for purchase fulfillment.
///
/// **Authentication**: This endpoint requires project authentication.
///
- /// Payment created successfully. Returns the ID and link to complete the payment.
+ /// Product purchased successfully. Returns the transaction used for the purchase.
/// A server side error occurred.
- public virtual System.Threading.Tasks.Task CreatePaymentAsync(Body13 body)
+ public virtual System.Threading.Tasks.Task PaymentsPurchaseAsync(string id, Body13 body)
{
- return CreatePaymentAsync(body, System.Threading.CancellationToken.None);
+ return PaymentsPurchaseAsync(id, body, System.Threading.CancellationToken.None);
}
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
///
- /// Create Payment
+ /// Complete Payment
///
///
- /// Create a payment to be executed. Users can complete the payment via hosted UI (link is returned), a transaction execution referencing the product ID, or embedded widgets with the product ID.
+ /// Completes a payment using its default token and amount. If the user does not have sufficient funds in the product's default payment token a 402 status will be returned containing a link and raw quote for purchase fulfillment.
///
/// **Authentication**: This endpoint requires project authentication.
///
- /// Payment created successfully. Returns the ID and link to complete the payment.
+ /// Product purchased successfully. Returns the transaction used for the purchase.
/// A server side error occurred.
- public virtual async System.Threading.Tasks.Task CreatePaymentAsync(Body13 body, System.Threading.CancellationToken cancellationToken)
+ public virtual async System.Threading.Tasks.Task PaymentsPurchaseAsync(string id, Body13 body, System.Threading.CancellationToken cancellationToken)
{
+ if (id == null)
+ throw new System.ArgumentNullException("id");
+
var client_ = _httpClient;
var disposeClient_ = false;
try
@@ -3699,8 +4016,9 @@ public virtual async System.Threading.Tasks.Task CreatePaymentAsync(
var urlBuilder_ = new System.Text.StringBuilder();
if (!string.IsNullOrEmpty(_baseUrl)) urlBuilder_.Append(_baseUrl);
- // Operation Path: "v1/payments"
- urlBuilder_.Append("v1/payments");
+ // Operation Path: "v1/payments/{id}"
+ urlBuilder_.Append("v1/payments/");
+ urlBuilder_.Append(System.Uri.EscapeDataString(ConvertToString(id, System.Globalization.CultureInfo.InvariantCulture)));
PrepareRequest(client_, request_, urlBuilder_);
@@ -3779,32 +4097,28 @@ public virtual async System.Threading.Tasks.Task CreatePaymentAsync(
}
///
- /// Complete Payment
+ /// Get Payment History
///
///
- /// Completes a payment using its default token and amount. If the user does not have sufficient funds in the product's default payment token a 402 status will be returned containing a link and raw quote for purchase fulfillment.
- ///
- /// **Authentication**: This endpoint requires project authentication.
+ /// Get payment history for a specific payment link
///
- /// Product purchased successfully. Returns the transaction used for the purchase.
+ /// Payment history retrieved successfully
/// A server side error occurred.
- public virtual System.Threading.Tasks.Task PaymentsPurchaseAsync(string id, Body14 body)
+ public virtual System.Threading.Tasks.Task GetPaymentHistoryAsync(string id)
{
- return PaymentsPurchaseAsync(id, body, System.Threading.CancellationToken.None);
+ return GetPaymentHistoryAsync(id, System.Threading.CancellationToken.None);
}
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
///
- /// Complete Payment
+ /// Get Payment History
///
///
- /// Completes a payment using its default token and amount. If the user does not have sufficient funds in the product's default payment token a 402 status will be returned containing a link and raw quote for purchase fulfillment.
- ///
- /// **Authentication**: This endpoint requires project authentication.
+ /// Get payment history for a specific payment link
///
- /// Product purchased successfully. Returns the transaction used for the purchase.
+ /// Payment history retrieved successfully
/// A server side error occurred.
- public virtual async System.Threading.Tasks.Task PaymentsPurchaseAsync(string id, Body14 body, System.Threading.CancellationToken cancellationToken)
+ public virtual async System.Threading.Tasks.Task GetPaymentHistoryAsync(string id, System.Threading.CancellationToken cancellationToken)
{
if (id == null)
throw new System.ArgumentNullException("id");
@@ -3815,11 +4129,7 @@ public virtual async System.Threading.Tasks.Task PaymentsPurchaseAsy
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
- var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(body, JsonSerializerSettings);
- var content_ = new System.Net.Http.StringContent(json_);
- content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json");
- request_.Content = content_;
- request_.Method = new System.Net.Http.HttpMethod("POST");
+ request_.Method = new System.Net.Http.HttpMethod("GET");
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
var urlBuilder_ = new System.Text.StringBuilder();
@@ -3863,26 +4173,22 @@ public virtual async System.Threading.Tasks.Task PaymentsPurchaseAsy
else
if (status_ == 400)
{
- string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
- throw new ThirdwebApiException("Invalid request parameters.", status_, responseText_, headers_, null);
- }
- else
- if (status_ == 401)
- {
- string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
- throw new ThirdwebApiException("Authentication required. For backend usage, include `x-secret-key` header. For frontend usage, include `x-client-id` + `Authorization: Bearer ` headers.", status_, responseText_, headers_, null);
- }
- else
- if (status_ == 402)
- {
- string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
- throw new ThirdwebApiException("Payment required. Insufficient wallet balance to complete the purchase.", status_, responseText_, headers_, null);
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ThirdwebApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ThirdwebApiException("Bad request", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
- if (status_ == 500)
+ if (status_ == 404)
{
- string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
- throw new ThirdwebApiException("Internal server error. This may occur due to network connectivity issues, wallet creation failures, or transaction execution failures.", status_, responseText_, headers_, null);
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ThirdwebApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ throw new ThirdwebApiException("Payment link not found", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
{
@@ -3912,9 +4218,9 @@ public virtual async System.Threading.Tasks.Task PaymentsPurchaseAsy
///
/// **Authentication**: This endpoint requires project authentication and wallet authentication. For backend usage, use `x-secret-key` header. For frontend usage, use `x-client-id` + `Authorization: Bearer <jwt>` headers.
///
- /// Token deployed successfully. The chain ID and contract address are returned.
+ /// The token is being deployed. Returns the predicted token address.
/// A server side error occurred.
- public virtual System.Threading.Tasks.Task CreateTokenAsync(Body15 body)
+ public virtual System.Threading.Tasks.Task CreateTokenAsync(Body14 body)
{
return CreateTokenAsync(body, System.Threading.CancellationToken.None);
}
@@ -3928,9 +4234,9 @@ public virtual System.Threading.Tasks.Task CreateTokenAsync(Body15 b
///
/// **Authentication**: This endpoint requires project authentication and wallet authentication. For backend usage, use `x-secret-key` header. For frontend usage, use `x-client-id` + `Authorization: Bearer <jwt>` headers.
///
- /// Token deployed successfully. The chain ID and contract address are returned.
+ /// The token is being deployed. Returns the predicted token address.
/// A server side error occurred.
- public virtual async System.Threading.Tasks.Task CreateTokenAsync(Body15 body, System.Threading.CancellationToken cancellationToken)
+ public virtual async System.Threading.Tasks.Task CreateTokenAsync(Body14 body, System.Threading.CancellationToken cancellationToken)
{
var client_ = _httpClient;
var disposeClient_ = false;
@@ -3973,9 +4279,9 @@ public virtual async System.Threading.Tasks.Task CreateTokenAsync(Bo
ProcessResponse(client_, response_);
var status_ = (int)response_.StatusCode;
- if (status_ == 200)
+ if (status_ == 202)
{
- var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
if (objectResponse_.Object == null)
{
throw new ThirdwebApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
@@ -4044,7 +4350,7 @@ public virtual async System.Threading.Tasks.Task CreateTokenAsync(Bo
/// Limit tokens to a specific name.
/// Tokens returned successfully.
/// A server side error occurred.
- public virtual System.Threading.Tasks.Task ListTokensAsync(int? limit, int? page, int? chainId, string tokenAddress, string symbol, string name)
+ public virtual System.Threading.Tasks.Task ListTokensAsync(int? limit, int? page, int? chainId, string tokenAddress, string symbol, string name)
{
return ListTokensAsync(limit, page, chainId, tokenAddress, symbol, name, System.Threading.CancellationToken.None);
}
@@ -4068,7 +4374,7 @@ public virtual System.Threading.Tasks.Task ListTokensAsync(int? limi
/// Limit tokens to a specific name.
/// Tokens returned successfully.
/// A server side error occurred.
- public virtual async System.Threading.Tasks.Task ListTokensAsync(int? limit, int? page, int? chainId, string tokenAddress, string symbol, string name, System.Threading.CancellationToken cancellationToken)
+ public virtual async System.Threading.Tasks.Task ListTokensAsync(int? limit, int? page, int? chainId, string tokenAddress, string symbol, string name, System.Threading.CancellationToken cancellationToken)
{
var client_ = _httpClient;
var disposeClient_ = false;
@@ -4135,7 +4441,7 @@ public virtual async System.Threading.Tasks.Task ListTokensAsync(int
var status_ = (int)response_.StatusCode;
if (status_ == 200)
{
- var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
if (objectResponse_.Object == null)
{
throw new ThirdwebApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
@@ -4194,7 +4500,7 @@ public virtual async System.Threading.Tasks.Task ListTokensAsync(int
/// Page number for pagination, starting from 1.
/// Token owners retrieved successfully. Returns owners with pagination information.
/// A server side error occurred.
- public virtual System.Threading.Tasks.Task GetTokenOwnersAsync(int chainId, string address, int? limit, int? page)
+ public virtual System.Threading.Tasks.Task GetTokenOwnersAsync(int chainId, string address, int? limit, int? page)
{
return GetTokenOwnersAsync(chainId, address, limit, page, System.Threading.CancellationToken.None);
}
@@ -4214,7 +4520,7 @@ public virtual System.Threading.Tasks.Task GetTokenOwnersAsync(int c
/// Page number for pagination, starting from 1.
/// Token owners retrieved successfully. Returns owners with pagination information.
/// A server side error occurred.
- public virtual async System.Threading.Tasks.Task GetTokenOwnersAsync(int chainId, string address, int? limit, int? page, System.Threading.CancellationToken cancellationToken)
+ public virtual async System.Threading.Tasks.Task GetTokenOwnersAsync(int chainId, string address, int? limit, int? page, System.Threading.CancellationToken cancellationToken)
{
if (chainId == null)
throw new System.ArgumentNullException("chainId");
@@ -4275,7 +4581,7 @@ public virtual async System.Threading.Tasks.Task GetTokenOwnersAsync
var status_ = (int)response_.StatusCode;
if (status_ == 200)
{
- var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
if (objectResponse_.Object == null)
{
throw new ThirdwebApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
@@ -4327,40 +4633,32 @@ public virtual async System.Threading.Tasks.Task GetTokenOwnersAsync
}
///
- /// Chat
+ /// Swap or Bridge Tokens
///
///
- /// Thirdweb AI chat completion API (BETA).
- ///
- /// Send natural language queries to interact with any EVM chain, read data, prepare transactions, swap tokens, deploy contracts, payments and more.
- ///
- ///
+ /// Swap one token for another using the optimal route available. You can specify a tokenIn amount (if exact='input') or tokenOut amount (if exact='output'), but not both. The corresponding output or input amount will be returned as the quote.
///
- /// **Authentication**: Pass `x-client-id` header for frontend usage from allowlisted origins or `x-secret-key` for backend usage.
+ /// **Authentication**: This endpoint requires project authentication and wallet authentication. For backend usage, use `x-secret-key` header. For frontend usage, use `x-client-id` + `Authorization: Bearer <jwt>` headers.
///
- /// AI assistant response or SSE stream when stream=true
+ /// Swap completed successfully. Returns the transaction used for the swap.
/// A server side error occurred.
- public virtual System.Threading.Tasks.Task ChatAsync(Body16 body)
+ public virtual System.Threading.Tasks.Task BridgeSwapAsync(Body15 body)
{
- return ChatAsync(body, System.Threading.CancellationToken.None);
+ return BridgeSwapAsync(body, System.Threading.CancellationToken.None);
}
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
///
- /// Chat
+ /// Swap or Bridge Tokens
///
///
- /// Thirdweb AI chat completion API (BETA).
- ///
- /// Send natural language queries to interact with any EVM chain, read data, prepare transactions, swap tokens, deploy contracts, payments and more.
- ///
- ///
+ /// Swap one token for another using the optimal route available. You can specify a tokenIn amount (if exact='input') or tokenOut amount (if exact='output'), but not both. The corresponding output or input amount will be returned as the quote.
///
- /// **Authentication**: Pass `x-client-id` header for frontend usage from allowlisted origins or `x-secret-key` for backend usage.
+ /// **Authentication**: This endpoint requires project authentication and wallet authentication. For backend usage, use `x-secret-key` header. For frontend usage, use `x-client-id` + `Authorization: Bearer <jwt>` headers.
///
- /// AI assistant response or SSE stream when stream=true
+ /// Swap completed successfully. Returns the transaction used for the swap.
/// A server side error occurred.
- public virtual async System.Threading.Tasks.Task ChatAsync(Body16 body, System.Threading.CancellationToken cancellationToken)
+ public virtual async System.Threading.Tasks.Task BridgeSwapAsync(Body15 body, System.Threading.CancellationToken cancellationToken)
{
var client_ = _httpClient;
var disposeClient_ = false;
@@ -4377,8 +4675,8 @@ public virtual async System.Threading.Tasks.Task ChatAsync(Body16 bo
var urlBuilder_ = new System.Text.StringBuilder();
if (!string.IsNullOrEmpty(_baseUrl)) urlBuilder_.Append(_baseUrl);
- // Operation Path: "ai/chat"
- urlBuilder_.Append("ai/chat");
+ // Operation Path: "v1/bridge/swap"
+ urlBuilder_.Append("v1/bridge/swap");
PrepareRequest(client_, request_, urlBuilder_);
@@ -4405,7 +4703,7 @@ public virtual async System.Threading.Tasks.Task ChatAsync(Body16 bo
var status_ = (int)response_.StatusCode;
if (status_ == 200)
{
- var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
if (objectResponse_.Object == null)
{
throw new ThirdwebApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
@@ -4413,16 +4711,146 @@ public virtual async System.Threading.Tasks.Task ChatAsync(Body16 bo
return objectResponse_.Object;
}
else
+ if (status_ == 400)
{
- var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
- throw new ThirdwebApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
+ string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ThirdwebApiException("Invalid request parameters.", status_, responseText_, headers_, null);
}
- }
- finally
- {
- if (disposeResponse_)
- response_.Dispose();
- }
+ else
+ if (status_ == 401)
+ {
+ string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ThirdwebApiException("Authentication required. For backend usage, include `x-secret-key` header. For frontend usage, include `x-client-id` + `Authorization: Bearer ` headers.", status_, responseText_, headers_, null);
+ }
+ else
+ if (status_ == 402)
+ {
+ string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ThirdwebApiException("Payment required. Insufficient wallet balance to complete the purchase.", status_, responseText_, headers_, null);
+ }
+ else
+ if (status_ == 500)
+ {
+ string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ThirdwebApiException("Internal server error. This may occur due to network connectivity issues, wallet creation failures, or transaction execution failures.", status_, responseText_, headers_, null);
+ }
+ else
+ {
+ var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ThirdwebApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
+ }
+ }
+ finally
+ {
+ if (disposeResponse_)
+ response_.Dispose();
+ }
+ }
+ }
+ finally
+ {
+ if (disposeClient_)
+ client_.Dispose();
+ }
+ }
+
+ ///
+ /// Chat
+ ///
+ ///
+ /// Thirdweb AI chat completion API (BETA).
+ ///
+ /// Send natural language queries to interact with any EVM chain, read data, prepare transactions, swap tokens, deploy contracts, payments and more.
+ ///
+ /// Compatible with standard OpenAI API chat completion format, can be used raw or with any popular AI library.
+ ///
+ /// **Authentication**: Pass `x-client-id` header for frontend usage from allowlisted origins or `x-secret-key` for backend usage.
+ ///
+ /// AI assistant response or SSE stream when stream=true
+ /// A server side error occurred.
+ public virtual System.Threading.Tasks.Task ChatAsync(Body16 body)
+ {
+ return ChatAsync(body, System.Threading.CancellationToken.None);
+ }
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Chat
+ ///
+ ///
+ /// Thirdweb AI chat completion API (BETA).
+ ///
+ /// Send natural language queries to interact with any EVM chain, read data, prepare transactions, swap tokens, deploy contracts, payments and more.
+ ///
+ /// Compatible with standard OpenAI API chat completion format, can be used raw or with any popular AI library.
+ ///
+ /// **Authentication**: Pass `x-client-id` header for frontend usage from allowlisted origins or `x-secret-key` for backend usage.
+ ///
+ /// AI assistant response or SSE stream when stream=true
+ /// A server side error occurred.
+ public virtual async System.Threading.Tasks.Task ChatAsync(Body16 body, System.Threading.CancellationToken cancellationToken)
+ {
+ var client_ = _httpClient;
+ var disposeClient_ = false;
+ try
+ {
+ using (var request_ = new System.Net.Http.HttpRequestMessage())
+ {
+ var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(body, JsonSerializerSettings);
+ var content_ = new System.Net.Http.StringContent(json_);
+ content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json");
+ request_.Content = content_;
+ request_.Method = new System.Net.Http.HttpMethod("POST");
+ request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
+
+ var urlBuilder_ = new System.Text.StringBuilder();
+ if (!string.IsNullOrEmpty(_baseUrl)) urlBuilder_.Append(_baseUrl);
+ // Operation Path: "ai/chat"
+ urlBuilder_.Append("ai/chat");
+
+ PrepareRequest(client_, request_, urlBuilder_);
+
+ var url_ = urlBuilder_.ToString();
+ request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
+
+ PrepareRequest(client_, request_, url_);
+
+ var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ var disposeResponse_ = true;
+ try
+ {
+ var headers_ = new System.Collections.Generic.Dictionary>();
+ foreach (var item_ in response_.Headers)
+ headers_[item_.Key] = item_.Value;
+ if (response_.Content != null && response_.Content.Headers != null)
+ {
+ foreach (var item_ in response_.Content.Headers)
+ headers_[item_.Key] = item_.Value;
+ }
+
+ ProcessResponse(client_, response_);
+
+ var status_ = (int)response_.StatusCode;
+ if (status_ == 200)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ThirdwebApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ return objectResponse_.Object;
+ }
+ else
+ {
+ var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
+ throw new ThirdwebApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
+ }
+ }
+ finally
+ {
+ if (disposeResponse_)
+ response_.Dispose();
+ }
}
}
finally
@@ -4438,7 +4866,17 @@ public virtual async System.Threading.Tasks.Task ChatAsync(Body16 bo
///
/// Model Context Protocol (MCP) server endpoint that exposes all thirdweb API endpoints as MCP tools. This allows LLMs and AI assistants to interact with the thirdweb API through the standardized MCP protocol.
///
- /// Authentication via x-secret-key is required for all requests.
+ /// Add this MCP server to any MCP client:
+ ///
+ /// ```json
+ /// {
+ /// "mcpServers": {
+ /// "thirdweb-api": {
+ /// "url": "https://api.thirdweb.com/mcp?secretKey=YOUR_SECRET_KEY_HERE"
+ /// }
+ /// }
+ /// }
+ /// ```
///
/// MCP response
/// A server side error occurred.
@@ -4454,7 +4892,17 @@ public virtual System.Threading.Tasks.Task