From 3744fdb772bef5bd28359a5d1c8adf2d164ab5e5 Mon Sep 17 00:00:00 2001 From: 0xFirekeeper <0xFirekeeper@gmail.com> Date: Fri, 5 Sep 2025 04:33:35 +0700 Subject: [PATCH 1/6] Refactor wallet user API integration to use tw api Migrates dashboard wallet user queries from manual fetch calls to the new @thirdweb-dev/api client, updating search, listing, and transformation logic in searchUsers.ts and useEmbeddedWallets.ts. Updates API client usage and types in sdk.gen.ts to match new endpoints and naming conventions. Adds @thirdweb-dev/api as a dependency in package.json. Closes BLD-243 --- apps/dashboard/package.json | 1 + .../searchUsers.ts | 166 +- .../src/@/hooks/useEmbeddedWallets.ts | 135 +- packages/api/src/client/sdk.gen.ts | 1058 ++-- packages/api/src/client/types.gen.ts | 4833 +++++++++++------ pnpm-lock.yaml | 9 +- 6 files changed, 3944 insertions(+), 2258 deletions(-) diff --git a/apps/dashboard/package.json b/apps/dashboard/package.json index 17484f66109..d8e299df326 100644 --- a/apps/dashboard/package.json +++ b/apps/dashboard/package.json @@ -23,6 +23,7 @@ "@shazow/whatsabi": "0.22.2", "@tanstack/react-query": "5.81.5", "@tanstack/react-table": "^8.21.3", + "@thirdweb-dev/api": "workspace:*", "@thirdweb-dev/service-utils": "workspace:*", "@thirdweb-dev/vault-sdk": "workspace:*", "@vercel/functions": "2.2.2", diff --git a/apps/dashboard/src/@/components/in-app-wallet-users-content/searchUsers.ts b/apps/dashboard/src/@/components/in-app-wallet-users-content/searchUsers.ts index b772bab0c57..9d5720eb291 100644 --- a/apps/dashboard/src/@/components/in-app-wallet-users-content/searchUsers.ts +++ b/apps/dashboard/src/@/components/in-app-wallet-users-content/searchUsers.ts @@ -1,7 +1,80 @@ +import type { + ListUserWalletsData, + ListUserWalletsResponses, +} from "@thirdweb-dev/api"; +import { configure, listUserWallets } from "@thirdweb-dev/api"; import type { WalletUser } from "thirdweb/wallets"; -import { THIRDWEB_EWS_API_HOST } from "@/constants/urls"; import type { SearchType } from "./types"; +// Configure the API client to use the correct base URL +const THIRDWEB_API_HOST = + process.env.NEXT_PUBLIC_THIRDWEB_API_HOST || "https://api.thirdweb.com"; +configure({ + override: { + baseUrl: THIRDWEB_API_HOST, + }, +}); + +// Extract types from the generated API +type APIWallet = ListUserWalletsResponses[200]["result"]["wallets"][0]; +type APIProfile = APIWallet["profiles"][0]; + +// Transform API response to match existing WalletUser format +function transformToWalletUser(apiWallet: APIWallet): WalletUser { + return { + id: getProfileId(apiWallet.profiles[0]) || "", + linkedAccounts: apiWallet.profiles.map((profile) => { + // Create details object based on the profile data + let details: + | { email: string; [key: string]: string } + | { phone: string; [key: string]: string } + | { address: string; [key: string]: string } + | { id: string; [key: string]: string }; + + const profileId = getProfileId(profile); + + if ("email" in profile && profile.email) { + details = { email: profile.email, id: profileId }; + } else if ("phone" in profile && profile.phone) { + details = { phone: profile.phone, id: profileId }; + } else if ("walletAddress" in profile && profile.walletAddress) { + details = { address: profile.walletAddress, id: profileId }; + } else { + details = { id: profileId }; + } + + return { + type: profile.type, + details, + }; + }), + wallets: apiWallet.address + ? [ + { + address: apiWallet.address, + createdAt: apiWallet.createdAt || new Date().toISOString(), + type: "enclave" as const, + }, + ] + : [], + }; +} + +// Helper function to safely get ID from any profile type +function getProfileId(profile: APIProfile | undefined): string { + if (!profile) return ""; + + if ("id" in profile) { + return profile.id; + } else if ("credentialId" in profile) { + return profile.credentialId; + } else if ("identifier" in profile) { + return profile.identifier; + } + + return ""; +} + export async function searchUsers( authToken: string, clientId: string | undefined, @@ -10,50 +83,57 @@ export async function searchUsers( searchType: SearchType, query: string, ): Promise { - const url = new URL(`${THIRDWEB_EWS_API_HOST}/api/2024-05-05/account/list`); + try { + // Prepare query parameters + const queryParams: ListUserWalletsData["query"] = { + limit: 50, + }; - // Add clientId or ecosystemSlug parameter - if (ecosystemSlug) { - url.searchParams.append("ecosystemSlug", `ecosystem.${ecosystemSlug}`); - } else if (clientId) { - url.searchParams.append("clientId", clientId); - } + // Add search parameter based on search type + switch (searchType) { + case "email": + queryParams.email = query; + break; + case "phone": + queryParams.phone = query; + break; + case "id": + queryParams.id = query; + break; + case "address": + queryParams.address = query; + break; + case "externalWallet": + queryParams.externalWalletAddress = query; + break; + } - // Add search parameter based on search type - switch (searchType) { - case "email": - url.searchParams.append("email", query); - break; - case "phone": - url.searchParams.append("phone", query); - break; - case "id": - url.searchParams.append("id", query); - break; - case "address": - url.searchParams.append("address", query); - break; - case "externalWallet": - url.searchParams.append("externalWalletAddress", query); - break; - } + // Use the generated API function with Bearer authentication + const response = await listUserWallets({ + query: queryParams, + headers: { + Authorization: `Bearer ${authToken}`, + "Content-Type": "application/json", + "x-thirdweb-team-id": teamId, + ...(clientId && { "x-client-id": clientId }), + ...(ecosystemSlug && { + "x-ecosystem-id": `ecosystem.${ecosystemSlug}`, + }), + }, + }); - const response = await fetch(url.toString(), { - headers: { - Authorization: `Bearer ${authToken}`, - "Content-Type": "application/json", - "x-thirdweb-team-id": teamId, - ...(clientId && { "x-client-id": clientId }), - }, - method: "GET", - }); - - if (!response.ok) { - throw new Error( - `Failed to search users: ${response.status} ${response.statusText}`, - ); - } + // Handle response + if (response.error || !response.data) { + console.error( + "Error searching users:", + response.error || "No data returned", + ); + return []; + } - const data = await response.json(); - return data.users as WalletUser[]; + return response.data.result.wallets.map(transformToWalletUser); + } catch (error) { + console.error("Error searching users:", error); + return []; + } } diff --git a/apps/dashboard/src/@/hooks/useEmbeddedWallets.ts b/apps/dashboard/src/@/hooks/useEmbeddedWallets.ts index 2a5bf9ad1a4..227db779e1f 100644 --- a/apps/dashboard/src/@/hooks/useEmbeddedWallets.ts +++ b/apps/dashboard/src/@/hooks/useEmbeddedWallets.ts @@ -1,9 +1,26 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; +import type { + ListUserWalletsData, + ListUserWalletsResponses, +} from "@thirdweb-dev/api"; +import { configure, listUserWallets } from "@thirdweb-dev/api"; import { useActiveAccount } from "thirdweb/react"; import type { WalletUser } from "thirdweb/wallets"; -import { THIRDWEB_EWS_API_HOST } from "@/constants/urls"; import { embeddedWalletsKeys } from "../query-keys/cache-keys"; +// Configure the API client to use the correct base URL +const THIRDWEB_API_HOST = + process.env.NEXT_PUBLIC_THIRDWEB_API_HOST || "https://api.thirdweb.com"; +configure({ + override: { + baseUrl: THIRDWEB_API_HOST, + }, +}); + +// Extract types from the generated API +type APIWallet = ListUserWalletsResponses[200]["result"]["wallets"][0]; +type APIProfile = APIWallet["profiles"][0]; + const fetchAccountList = ({ jwt, clientId, @@ -18,37 +35,103 @@ const fetchAccountList = ({ pageNumber: number; }) => { return async () => { - const url = new URL(`${THIRDWEB_EWS_API_HOST}/api/2024-05-05/account/list`); + try { + // Prepare query parameters for the new API + const queryParams: ListUserWalletsData["query"] = { + page: pageNumber, + limit: 50, // Keep the same page size + }; - // Add clientId or ecosystemSlug parameter - if (ecosystemSlug) { - url.searchParams.append("ecosystemSlug", `ecosystem.${ecosystemSlug}`); - } else if (clientId) { - url.searchParams.append("clientId", clientId); - } + // Use the generated API function with Bearer authentication + const response = await listUserWallets({ + query: queryParams, + headers: { + Authorization: `Bearer ${jwt}`, + "Content-Type": "application/json", + "x-thirdweb-team-id": teamId, + ...(clientId && { "x-client-id": clientId }), + ...(ecosystemSlug && { + "x-ecosystem-id": `ecosystem.${ecosystemSlug}`, + }), + }, + }); - url.searchParams.append("page", pageNumber.toString()); - - const res = await fetch(url.href, { - headers: { - Authorization: `Bearer ${jwt}`, - "Content-Type": "application/json", - "x-thirdweb-team-id": teamId, - ...(clientId && { "x-client-id": clientId }), - }, - method: "GET", - }); - if (!res.ok) { - throw new Error(`Failed to fetch wallets: ${await res.text()}`); - } + // Handle response + if (response.error || !response.data) { + const errorMessage = + typeof response.error === "string" + ? response.error + : "No data returned"; + throw new Error(errorMessage); + } - const json = await res.json(); - return json as { - users: WalletUser[]; - }; + // Transform the response to match the expected format + return { + users: response.data.result.wallets.map(transformToWalletUser), + }; + } catch (error) { + console.error("Failed to fetch wallets:", error); + throw error; + } }; }; +// Transform API response to match existing WalletUser format +function transformToWalletUser(apiWallet: APIWallet): WalletUser { + return { + id: getProfileId(apiWallet.profiles[0]) || "", + linkedAccounts: apiWallet.profiles.map((profile) => { + // Create details object based on the profile data + let details: + | { email: string; [key: string]: string } + | { phone: string; [key: string]: string } + | { address: string; [key: string]: string } + | { id: string; [key: string]: string }; + + const profileId = getProfileId(profile); + + if ("email" in profile && profile.email) { + details = { email: profile.email, id: profileId }; + } else if ("phone" in profile && profile.phone) { + details = { phone: profile.phone, id: profileId }; + } else if ("walletAddress" in profile && profile.walletAddress) { + details = { address: profile.walletAddress, id: profileId }; + } else { + details = { id: profileId }; + } + + return { + type: profile.type, + details, + }; + }), + wallets: apiWallet.address + ? [ + { + address: apiWallet.address, + createdAt: apiWallet.createdAt || new Date().toISOString(), + type: "enclave" as const, + }, + ] + : [], + }; +} + +// Helper function to safely get ID from any profile type +function getProfileId(profile: APIProfile | undefined): string { + if (!profile) return ""; + + if ("id" in profile) { + return profile.id; + } else if ("credentialId" in profile) { + return profile.credentialId; + } else if ("identifier" in profile) { + return profile.identifier; + } + + return ""; +} + export function useEmbeddedWallets(params: { clientId?: string; ecosystemSlug?: string; diff --git a/packages/api/src/client/sdk.gen.ts b/packages/api/src/client/sdk.gen.ts index 3babdae4624..ae0575b8502 100644 --- a/packages/api/src/client/sdk.gen.ts +++ b/packages/api/src/client/sdk.gen.ts @@ -7,36 +7,56 @@ import type { } from "./client/index.js"; import { client as _heyApiClient } from "./client.gen.js"; import type { - BuyTokenWithUsdData, - BuyTokenWithUsdErrors, - BuyTokenWithUsdResponses, - CreateWalletData, - CreateWalletErrors, - CreateWalletResponses, + BridgeSwapData, + BridgeSwapErrors, + BridgeSwapResponses, + ChatData, + ChatResponses, + CompleteAuthenticationData, + CompleteAuthenticationErrors, + CompleteAuthenticationResponses, + CreatePaymentData, + CreatePaymentErrors, + CreatePaymentResponses, + CreateServerWalletData, + CreateServerWalletErrors, + CreateServerWalletResponses, + CreateTokenData, + CreateTokenErrors, + CreateTokenResponses, + CreateUserWalletData, + CreateUserWalletErrors, + CreateUserWalletResponses, DeployContractData, DeployContractErrors, DeployContractResponses, - GeneratePasskeyChallengeData, - GeneratePasskeyChallengeErrors, - GeneratePasskeyChallengeResponses, - GenerateSiwePayloadData, - GenerateSiwePayloadErrors, - GenerateSiwePayloadResponses, GetContractEventsData, GetContractEventsErrors, GetContractEventsResponses, + GetContractMetadataData, + GetContractMetadataErrors, + GetContractMetadataResponses, + GetContractSignaturesData, + GetContractSignaturesErrors, + GetContractSignaturesResponses, GetContractTransactionsData, GetContractTransactionsErrors, GetContractTransactionsResponses, + GetMyWalletData, + GetMyWalletErrors, + GetMyWalletResponses, + GetPaymentHistoryData, + GetPaymentHistoryErrors, + GetPaymentHistoryResponses, + GetTokenOwnersData, + GetTokenOwnersErrors, + GetTokenOwnersResponses, GetTransactionByIdData, GetTransactionByIdErrors, GetTransactionByIdResponses, GetWalletBalanceData, GetWalletBalanceErrors, GetWalletBalanceResponses, - GetWalletDetailsData, - GetWalletDetailsErrors, - GetWalletDetailsResponses, GetWalletNftsData, GetWalletNftsErrors, GetWalletNftsResponses, @@ -46,26 +66,37 @@ import type { GetWalletTransactionsData, GetWalletTransactionsErrors, GetWalletTransactionsResponses, - InitOauthData, - InitOauthErrors, + InitiateAuthenticationData, + InitiateAuthenticationErrors, + InitiateAuthenticationResponses, ListContractsData, ListContractsErrors, ListContractsResponses, + ListServerWalletsData, + ListServerWalletsErrors, + ListServerWalletsResponses, + ListTokensData, + ListTokensErrors, + ListTokensResponses, ListTransactionsData, ListTransactionsErrors, ListTransactionsResponses, - ListWalletsData, - ListWalletsErrors, - ListWalletsResponses, + ListUserWalletsData, + ListUserWalletsErrors, + ListUserWalletsResponses, + LlmsTxtData, + LlmsTxtResponses, + McpServerData, + McpServerResponses, + PaymentsPurchaseData, + PaymentsPurchaseErrors, + PaymentsPurchaseResponses, ReadContractData, ReadContractErrors, ReadContractResponses, - SellTokenForUsdData, - SellTokenForUsdErrors, - SellTokenForUsdResponses, - SendCodeData, - SendCodeErrors, - SendCodeResponses, + SendTokensData, + SendTokensErrors, + SendTokensResponses, SendTransactionsData, SendTransactionsErrors, SendTransactionsResponses, @@ -75,18 +106,8 @@ import type { SignTypedDataData, SignTypedDataErrors, SignTypedDataResponses, - TransferTokenWithUsdData, - TransferTokenWithUsdErrors, - TransferTokenWithUsdResponses, - VerifyCodeData, - VerifyCodeErrors, - VerifyCodeResponses, - VerifyPasskeyData, - VerifyPasskeyErrors, - VerifyPasskeyResponses, - VerifySiweSignatureData, - VerifySiweSignatureErrors, - VerifySiweSignatureResponses, + SocialAuthenticationData, + SocialAuthenticationErrors, WriteContractData, WriteContractErrors, WriteContractResponses, @@ -110,21 +131,37 @@ export type Options< }; /** - * List Contracts - * Retrieves a list of all smart contracts imported by the authenticated client on the thirdweb dashboard. This endpoint provides access to contracts that have been added to your dashboard for management and interaction. Results include contract metadata, deployment information, and import timestamps. + * Initiate Auth + * Start any authentication flow in one unified endpoint. This endpoint supports all authentication methods including SMS, email, OAuth, passkey, and SIWE (Sign-In with Ethereum). * - * **Authentication**: This endpoint requires backend authentication using the `x-secret-key` header. The secret key should never be exposed publicly. + * **Supported Methods:** + * - **SMS** - Send verification code to phone number + * - **Email** - Send verification code to email address + * - **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=...` * - * **ABI Enrichment**: When `includeAbi=true`, the endpoint will fetch the contract ABI (Application Binary Interface) from the thirdweb contract service for each contract. The ABI contains function signatures, event definitions, and interface specifications required for contract interaction. + * **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 * - * **Metadata Enrichment**: When `includeMetadata=true`, the endpoint will fetch additional metadata from the thirdweb contract metadata service for each contract. This includes information like contract name, description, compilation details, and more. The metadata is returned in an optional `metadata` object within each contract. + * NOTE: for custom authentication (JWT, auth-payload) and for guest authentication, you can skip this step and use the `/complete` endpoint directly. + * + * **Authentication:** Requires `x-client-id` header for frontend usage or `x-secret-key` for backend usage. */ -export const listContracts = ( - options?: Options, +export const initiateAuthentication = ( + options?: Options, ) => { - return (options?.client ?? _heyApiClient).get< - ListContractsResponses, - ListContractsErrors, + return (options?.client ?? _heyApiClient).post< + InitiateAuthenticationResponses, + InitiateAuthenticationErrors, ThrowOnError >({ security: [ @@ -132,32 +169,57 @@ export const listContracts = ( name: "x-client-id", type: "apiKey", }, - { - name: "x-secret-key", - type: "apiKey", - }, - { - scheme: "bearer", - type: "http", - }, ], - url: "/v1/contracts", + url: "/v1/auth/initiate", ...options, + headers: { + "Content-Type": "application/json", + ...options?.headers, + }, }); }; /** - * Deploy Contract - * Deploy a new smart contract to a blockchain network. This endpoint allows you to deploy contracts by providing the contract source URL, target chain, constructor parameters, and optional salt for deterministic deployment. + * Complete Auth + * Complete the authentication flow and receive your wallet credentials. After initiating authentication, use this endpoint to submit the required verification data. * - * **Authentication**: This endpoint requires backend authentication using the `x-secret-key` header. The secret key should never be exposed publicly. + * **Completion Methods:** + * - **SMS/Email** - Submit the verification code you received + * - **Passkey** - Provide the WebAuthn signature response + * - **SIWE** - Submit your signed Ethereum message + * - **Guest** - Create an ephemeral guest wallet + * - **Custom (JWT, auth-payload)** - Send your JWT token or custom payload + * + * **Response:** + * - `isNewUser` - Whether this is a new wallet creation + * - `token` - JWT token for authenticated API requests + * - `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. */ -export const deployContract = ( - options?: Options, +export const completeAuthentication = ( + options?: Options, ) => { return (options?.client ?? _heyApiClient).post< - DeployContractResponses, - DeployContractErrors, + CompleteAuthenticationResponses, + CompleteAuthenticationErrors, ThrowOnError >({ security: [ @@ -165,16 +227,8 @@ export const deployContract = ( name: "x-client-id", type: "apiKey", }, - { - name: "x-secret-key", - type: "apiKey", - }, - { - scheme: "bearer", - type: "http", - }, ], - url: "/v1/contracts", + url: "/v1/auth/complete", ...options, headers: { "Content-Type": "application/json", @@ -184,137 +238,161 @@ export const deployContract = ( }; /** - * Read Contract Methods - * Executes multiple read-only contract method calls in a single batch request. This endpoint allows efficient batch reading from multiple contracts on the same chain, significantly reducing the number of HTTP requests needed. Each call specifies the contract address, method signature, and optional parameters. Results are returned in the same order as the input calls, with individual success/failure status for each operation. + * 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. * - * **Authentication**: Pass `x-client-id` header for frontend usage from allowlisted origins or `x-secret-key` for backend usage. + * **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 + * ``` */ -export const readContract = ( - options?: Options, +export const socialAuthentication = ( + options: Options, ) => { - return (options?.client ?? _heyApiClient).post< - ReadContractResponses, - ReadContractErrors, + return (options.client ?? _heyApiClient).get< + unknown, + SocialAuthenticationErrors, ThrowOnError >({ - security: [ - { - name: "x-client-id", - type: "apiKey", - }, - { - name: "x-secret-key", - type: "apiKey", - }, - { - scheme: "bearer", - type: "http", - }, - ], - url: "/v1/contracts/read", + url: "/v1/auth/social", ...options, - headers: { - "Content-Type": "application/json", - ...options?.headers, - }, }); }; /** - * Get Contract Transactions - * Retrieves transactions for a specific smart contract address across one or more blockchain networks. This endpoint provides comprehensive transaction data including block information, gas details, transaction status, and function calls. Results can be filtered, paginated, and sorted to meet specific requirements. + * Get My Wallet + * Retrieve the authenticated user's wallet information including wallet addresses and linked authentication wallets. This endpoint provides comprehensive user data for the currently authenticated session. * - * **Authentication**: Pass `x-client-id` header for frontend usage from allowlisted origins or `x-secret-key` for backend usage. + * **Returns:** + * - Primary wallet address + * - Smart wallet address (if available) + * - Wallet creation timestamp + * - Public key in hexadecimal format (if available) + * - All linked authentication profiles (email, phone, OAuth providers) + * + * **Authentication:** Requires `Authorization: Bearer ` header with a valid user authentication token. */ -export const getContractTransactions = ( - options: Options, +export const getMyWallet = ( + options?: Options, ) => { - return (options.client ?? _heyApiClient).get< - GetContractTransactionsResponses, - GetContractTransactionsErrors, + return (options?.client ?? _heyApiClient).get< + GetMyWalletResponses, + GetMyWalletErrors, ThrowOnError >({ security: [ { - name: "x-client-id", - type: "apiKey", + scheme: "bearer", + type: "http", }, { - name: "x-secret-key", + name: "x-client-id", type: "apiKey", }, - { - scheme: "bearer", - type: "http", - }, ], - url: "/v1/contracts/{address}/transactions", + url: "/v1/wallets/me", ...options, }); }; /** - * Get Contract Events - * Retrieves events emitted by a specific smart contract address across one or more blockchain networks. This endpoint provides comprehensive event data including block information, transaction details, event topics, and optional ABI decoding. Results can be filtered, paginated, and sorted to meet specific requirements. + * List User Wallets + * Get all user wallet details with filtering and pagination for your project. * - * **Authentication**: Pass `x-client-id` header for frontend usage from allowlisted origins or `x-secret-key` for backend usage. + * **Authentication**: This endpoint requires backend authentication using the `x-secret-key` header. The secret key should never be exposed publicly. */ -export const getContractEvents = ( - options: Options, +export const listUserWallets = ( + options?: Options, ) => { - return (options.client ?? _heyApiClient).get< - GetContractEventsResponses, - GetContractEventsErrors, + return (options?.client ?? _heyApiClient).get< + ListUserWalletsResponses, + ListUserWalletsErrors, ThrowOnError >({ security: [ - { - name: "x-client-id", - type: "apiKey", - }, { name: "x-secret-key", type: "apiKey", }, - { - scheme: "bearer", - type: "http", - }, ], - url: "/v1/contracts/{address}/events", + url: "/v1/wallets/user", ...options, }); }; /** - * Write Contract Methods - * Executes write operations (transactions) on smart contracts. This is a convenience endpoint that simplifies contract interaction by accepting method signatures and parameters directly, without requiring manual transaction encoding. All calls are executed against the same contract address and chain, making it ideal for batch operations. + * Create User Wallet + * Create a user wallet with a wallet based on their authentication strategy. This endpoint creates a wallet in advance that can be claimed later when the user authenticates. * - * **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 ` headers. + * **Authentication**: This endpoint requires backend authentication using the `x-secret-key` header. The secret key should never be exposed publicly. */ -export const writeContract = ( - options?: Options, +export const createUserWallet = ( + options?: Options, ) => { return (options?.client ?? _heyApiClient).post< - WriteContractResponses, - WriteContractErrors, + CreateUserWalletResponses, + CreateUserWalletErrors, ThrowOnError >({ security: [ - { - name: "x-client-id", - type: "apiKey", - }, { name: "x-secret-key", type: "apiKey", }, - { - scheme: "bearer", - type: "http", - }, ], - url: "/v1/contracts/write", + url: "/v1/wallets/user", ...options, headers: { "Content-Type": "application/json", @@ -324,65 +402,51 @@ export const writeContract = ( }; /** - * List Wallets - * Get all wallet details with pagination for your project. + * List Server Wallets + * Get all server wallet details with pagination for your project. * * **Authentication**: This endpoint requires backend authentication using the `x-secret-key` header. The secret key should never be exposed publicly. */ -export const listWallets = ( - options?: Options, +export const listServerWallets = ( + options?: Options, ) => { return (options?.client ?? _heyApiClient).get< - ListWalletsResponses, - ListWalletsErrors, + ListServerWalletsResponses, + ListServerWalletsErrors, ThrowOnError >({ security: [ - { - name: "x-client-id", - type: "apiKey", - }, { name: "x-secret-key", type: "apiKey", }, - { - scheme: "bearer", - type: "http", - }, ], - url: "/v1/wallets", + url: "/v1/wallets/server", ...options, }); }; /** - * Create Wallet - * Creates a server wallet from a unique identifier. If the wallet already exists, it will return the existing wallet. Requires project authentication with `x-secret-key` header. + * Create Server Wallet + * Creates a server wallet from a unique identifier. If the wallet already exists, it will return the existing wallet. + * + * **Authentication**: This endpoint requires backend authentication using the `x-secret-key` header. The secret key should never be exposed publicly. */ -export const createWallet = ( - options?: Options, +export const createServerWallet = ( + options?: Options, ) => { return (options?.client ?? _heyApiClient).post< - CreateWalletResponses, - CreateWalletErrors, + CreateServerWalletResponses, + CreateServerWalletErrors, ThrowOnError >({ security: [ - { - name: "x-client-id", - type: "apiKey", - }, { name: "x-secret-key", type: "apiKey", }, - { - scheme: "bearer", - type: "http", - }, ], - url: "/v1/wallets", + url: "/v1/wallets/server", ...options, headers: { "Content-Type": "application/json", @@ -392,8 +456,8 @@ export const createWallet = ( }; /** - * Get Wallet Native Balance - * Get native token balance for a wallet address across multiple blockchain networks. This endpoint retrieves native token balances (ETH, MATIC, BNB, etc.) for a given wallet address on multiple chains simultaneously, making it efficient for cross-chain native balance checking. + * Get Balance + * Get native or ERC20 token balance for a wallet address. Can retrieve live balances for any ERC20 token on a signle chain, or native token balances across multiple chains. * * **Authentication**: Pass `x-client-id` header for frontend usage from allowlisted origins or `x-secret-key` for backend usage. */ @@ -410,14 +474,6 @@ export const getWalletBalance = ( name: "x-client-id", type: "apiKey", }, - { - name: "x-secret-key", - type: "apiKey", - }, - { - scheme: "bearer", - type: "http", - }, ], url: "/v1/wallets/{address}/balance", ...options, @@ -425,7 +481,7 @@ export const getWalletBalance = ( }; /** - * Get Wallet Transactions + * Get Transactions * Retrieves transactions for a specific wallet address across one or more blockchain networks. This endpoint provides comprehensive transaction data including both incoming and outgoing transactions, with block information, gas details, transaction status, and function calls. Results can be filtered, paginated, and sorted to meet specific requirements. * * **Authentication**: Pass `x-client-id` header for frontend usage from allowlisted origins or `x-secret-key` for backend usage. @@ -443,14 +499,6 @@ export const getWalletTransactions = ( name: "x-client-id", type: "apiKey", }, - { - name: "x-secret-key", - type: "apiKey", - }, - { - scheme: "bearer", - type: "http", - }, ], url: "/v1/wallets/{address}/transactions", ...options, @@ -458,7 +506,7 @@ export const getWalletTransactions = ( }; /** - * Get Wallet Tokens + * 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. * * **Authentication**: Pass `x-client-id` header for frontend usage from allowlisted origins or `x-secret-key` for backend usage. @@ -476,14 +524,6 @@ export const getWalletTokens = ( name: "x-client-id", type: "apiKey", }, - { - name: "x-secret-key", - type: "apiKey", - }, - { - scheme: "bearer", - type: "http", - }, ], url: "/v1/wallets/{address}/tokens", ...options, @@ -491,7 +531,7 @@ export const getWalletTokens = ( }; /** - * Get Wallet NFTs + * Get NFTs * Retrieves NFTs for a specific wallet address across one or more blockchain networks. This endpoint provides comprehensive NFT data including metadata, attributes, and collection information. Results can be filtered by chain and paginated to meet specific requirements. * * **Authentication**: Pass `x-client-id` header for frontend usage from allowlisted origins or `x-secret-key` for backend usage. @@ -509,14 +549,6 @@ export const getWalletNfts = ( name: "x-client-id", type: "apiKey", }, - { - name: "x-secret-key", - type: "apiKey", - }, - { - scheme: "bearer", - type: "http", - }, ], url: "/v1/wallets/{address}/nfts", ...options, @@ -524,65 +556,63 @@ export const getWalletNfts = ( }; /** - * Get Wallet Details - * Retrieves detailed user information for a previously created wallet. This endpoint fetches user data including authentication details and linked accounts. + * Sign Message + * Signs an arbitrary message using the specified wallet. This endpoint supports both text and hexadecimal message formats. The signing is performed using thirdweb Engine with smart wallet support for gasless transactions. * - * **Authentication**: This endpoint requires backend authentication using the `x-secret-key` header. The secret key should never be exposed publicly. + * **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 ` headers. */ -export const getWalletDetails = ( - options: Options, +export const signMessage = ( + options?: Options, ) => { - return (options.client ?? _heyApiClient).get< - GetWalletDetailsResponses, - GetWalletDetailsErrors, + return (options?.client ?? _heyApiClient).post< + SignMessageResponses, + SignMessageErrors, ThrowOnError >({ security: [ { - name: "x-client-id", - type: "apiKey", + scheme: "bearer", + type: "http", }, { - name: "x-secret-key", + name: "x-client-id", type: "apiKey", }, - { - scheme: "bearer", - type: "http", - }, ], - url: "/v1/wallets/{address}", + url: "/v1/wallets/sign-message", ...options, + headers: { + "Content-Type": "application/json", + ...options?.headers, + }, }); }; /** - * Send Login Code - * Send email or phone code for wallet authentication + * Sign Typed Data + * Signs structured data according to the EIP-712 standard using the specified wallet. This is commonly used for secure message signing in DeFi protocols, NFT marketplaces, and other dApps that require structured data verification. The typed data includes domain separation and type definitions for enhanced security. + * + * **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 ` headers. */ -export const sendCode = ( - options?: Options, +export const signTypedData = ( + options?: Options, ) => { return (options?.client ?? _heyApiClient).post< - SendCodeResponses, - SendCodeErrors, + SignTypedDataResponses, + SignTypedDataErrors, ThrowOnError >({ security: [ { - name: "x-client-id", - type: "apiKey", + scheme: "bearer", + type: "http", }, { - name: "x-secret-key", + name: "x-client-id", type: "apiKey", }, - { - scheme: "bearer", - type: "http", - }, ], - url: "/v1/wallets/login/code", + url: "/v1/wallets/sign-typed-data", ...options, headers: { "Content-Type": "application/json", @@ -592,32 +622,36 @@ export const sendCode = ( }; /** - * Login with Code - * Verify email or phone code for wallet authentication + * Send Tokens + * Send tokens to multiple recipients in a single transaction batch. Supports native tokens (ETH, MATIC, etc.), ERC20 tokens, ERC721 NFTs, and ERC1155 tokens. The token type is automatically determined based on the provided parameters and ERC165 interface detection: + * + * - **Native Token**: No `tokenAddress` provided + * - **ERC20**: `tokenAddress` provided, no `tokenId` + * - **ERC721/ERC1155**: `tokenAddress` and `tokenId` provided. Auto detects contract type: + * - ERC721: quantity must be '1' + * - ERC1155: any quantity allowed (including '1') + * + * **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 ` headers. */ -export const verifyCode = ( - options?: Options, +export const sendTokens = ( + options?: Options, ) => { return (options?.client ?? _heyApiClient).post< - VerifyCodeResponses, - VerifyCodeErrors, + SendTokensResponses, + SendTokensErrors, ThrowOnError >({ security: [ { - name: "x-client-id", - type: "apiKey", + scheme: "bearer", + type: "http", }, { - name: "x-secret-key", + name: "x-client-id", type: "apiKey", }, - { - scheme: "bearer", - type: "http", - }, ], - url: "/v1/wallets/login/code/verify", + url: "/v1/wallets/send", ...options, headers: { "Content-Type": "application/json", @@ -627,77 +661,77 @@ export const verifyCode = ( }; /** - * Login with OAuth - * Initiate OAuth flow for a given provider (google, apple, github, etc). Open this URL in a browser to begin authentication. After authentication, the user will be redirected to the redirect URL with an authResult parameter. + * List Contracts + * Retrieves a list of all smart contracts imported by the authenticated client on the thirdweb dashboard. This endpoint provides access to contracts that have been added to your dashboard for management and interaction. Results include contract metadata, deployment information, and import timestamps. + * + * **Authentication**: This endpoint requires backend authentication using the `x-secret-key` header. The secret key should never be exposed publicly. + * + * **Note**: For detailed contract metadata including compilation information, ABI, and source code, use the dedicated metadata endpoint: `GET /v1/contracts/{chainId}/{address}/metadata`. */ -export const initOauth = ( - options: Options, +export const listContracts = ( + options?: Options, ) => { - return (options.client ?? _heyApiClient).get< - unknown, - InitOauthErrors, + return (options?.client ?? _heyApiClient).get< + ListContractsResponses, + ListContractsErrors, ThrowOnError >({ security: [ - { - name: "x-client-id", - type: "apiKey", - }, { name: "x-secret-key", type: "apiKey", }, - { - scheme: "bearer", - type: "http", - }, ], - url: "/v1/wallets/login/oauth/{provider}", + url: "/v1/contracts", ...options, }); }; /** - * Generate Passkey Challenge - * Generate passkey challenge for wallet authentication + * Deploy Contract + * Deploy a new smart contract to a blockchain network using raw bytecode. This endpoint allows you to deploy contracts by providing the contract bytecode, ABI, constructor parameters, and optional salt for deterministic deployment. + * + * **Authentication**: This endpoint requires backend authentication using the `x-secret-key` header. The secret key should never be exposed publicly. */ -export const generatePasskeyChallenge = ( - options: Options, +export const deployContract = ( + options?: Options, ) => { - return (options.client ?? _heyApiClient).get< - GeneratePasskeyChallengeResponses, - GeneratePasskeyChallengeErrors, + return (options?.client ?? _heyApiClient).post< + DeployContractResponses, + DeployContractErrors, ThrowOnError >({ security: [ { - name: "x-client-id", - type: "apiKey", + scheme: "bearer", + type: "http", }, { - name: "x-secret-key", + name: "x-client-id", type: "apiKey", }, - { - scheme: "bearer", - type: "http", - }, ], - url: "/v1/wallets/login/passkey", + url: "/v1/contracts", ...options, + headers: { + "Content-Type": "application/json", + ...options?.headers, + }, }); }; /** - * Login with Passkey - * Verify passkey challenge for wallet authentication + * Read Contract + * Executes multiple read-only contract method calls in a single batch request. This endpoint allows efficient batch reading from multiple contracts on the same chain, significantly reducing the number of HTTP requests needed. Each call specifies the contract address, method signature, and optional parameters. Results are returned in the same order as the input calls, with individual success/failure status for each operation. + * + * **Authentication**: Pass `x-client-id` header for frontend usage from allowlisted origins or `x-secret-key` for backend usage. */ -export const verifyPasskey = ( - options?: Options, +export const readContract = ( + options?: Options, ) => { return (options?.client ?? _heyApiClient).post< - VerifyPasskeyResponses, - VerifyPasskeyErrors, + ReadContractResponses, + ReadContractErrors, ThrowOnError >({ security: [ @@ -705,16 +739,41 @@ export const verifyPasskey = ( name: "x-client-id", type: "apiKey", }, - { - name: "x-secret-key", - type: "apiKey", - }, + ], + url: "/v1/contracts/read", + ...options, + headers: { + "Content-Type": "application/json", + ...options?.headers, + }, + }); +}; + +/** + * Write Contract + * Executes write operations (transactions) on smart contracts. This is a convenience endpoint that simplifies contract interaction by accepting method signatures and parameters directly, without requiring manual transaction encoding. All calls are executed against the same contract address and chain, making it ideal for batch operations. + * + * **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 ` headers. + */ +export const writeContract = ( + options?: Options, +) => { + return (options?.client ?? _heyApiClient).post< + WriteContractResponses, + WriteContractErrors, + ThrowOnError + >({ + security: [ { scheme: "bearer", type: "http", }, + { + name: "x-client-id", + type: "apiKey", + }, ], - url: "/v1/wallets/login/passkey/verify", + url: "/v1/contracts/write", ...options, headers: { "Content-Type": "application/json", @@ -724,15 +783,17 @@ export const verifyPasskey = ( }; /** - * Generate SIWE Payload - * Generate SIWE payload for wallet authentication + * Get Transactions + * Retrieves transactions for a specific smart contract address on a specific blockchain network. This endpoint provides comprehensive transaction data including block information, gas details, transaction status, and function calls. Results can be filtered, paginated, and sorted to meet specific requirements. + * + * **Authentication**: Pass `x-client-id` header for frontend usage from allowlisted origins or `x-secret-key` for backend usage. */ -export const generateSiwePayload = ( - options: Options, +export const getContractTransactions = ( + options: Options, ) => { return (options.client ?? _heyApiClient).get< - GenerateSiwePayloadResponses, - GenerateSiwePayloadErrors, + GetContractTransactionsResponses, + GetContractTransactionsErrors, ThrowOnError >({ security: [ @@ -740,52 +801,113 @@ export const generateSiwePayload = ( name: "x-client-id", type: "apiKey", }, + ], + url: "/v1/contracts/{chainId}/{address}/transactions", + ...options, + }); +}; + +/** + * Get Events + * Retrieves events emitted by a specific smart contract address on a specific blockchain network. This endpoint provides comprehensive event data including block information, transaction details, event topics, and optional ABI decoding. Results can be filtered, paginated, and sorted to meet specific requirements. + * + * **Authentication**: Pass `x-client-id` header for frontend usage from allowlisted origins or `x-secret-key` for backend usage. + */ +export const getContractEvents = ( + options: Options, +) => { + return (options.client ?? _heyApiClient).get< + GetContractEventsResponses, + GetContractEventsErrors, + ThrowOnError + >({ + security: [ { - name: "x-secret-key", + name: "x-client-id", type: "apiKey", }, - { - scheme: "bearer", - type: "http", - }, ], - url: "/v1/wallets/login/siwe", + url: "/v1/contracts/{chainId}/{address}/events", ...options, }); }; /** - * Login with SIWE - * Verify SIWE signature for wallet authentication + * Get Metadata + * Retrieves detailed metadata for a specific smart contract from the thirdweb contract metadata service. This includes compilation information, ABI, documentation, and other contract-related metadata. Note: Source code is excluded from the response to keep it lightweight and suitable for programmatic access. + * + * **Authentication**: This endpoint requires backend authentication using the `x-secret-key` header. The secret key should never be exposed publicly. + * + * **Metadata Source**: The metadata is fetched from the thirdweb contract metadata service and includes detailed Solidity compilation information, contract ABI, and developer documentation. */ -export const verifySiweSignature = ( - options?: Options, +export const getContractMetadata = ( + options: Options, ) => { - return (options?.client ?? _heyApiClient).post< - VerifySiweSignatureResponses, - VerifySiweSignatureErrors, + return (options.client ?? _heyApiClient).get< + GetContractMetadataResponses, + GetContractMetadataErrors, ThrowOnError >({ security: [ { - name: "x-client-id", + name: "x-secret-key", type: "apiKey", }, + ], + url: "/v1/contracts/{chainId}/{address}/metadata", + ...options, + }); +}; + +/** + * Get Signatures + * Retrieves human-readable ABI signatures for a specific smart contract. This endpoint fetches the contract metadata from the thirdweb service, extracts the ABI, and converts it into an array of human-readable function and event signatures that can be used directly with contract interaction methods. + * + * **Authentication**: This endpoint requires backend authentication using the `x-secret-key` header. The secret key should never be exposed publicly. + * + * **Usage**: The returned signatures can be used directly in contract read/write operations or event filtering. Each signature follows the standard Solidity format and includes function parameters, return types, state mutability, and event indexing information. + */ +export const getContractSignatures = ( + options: Options, +) => { + return (options.client ?? _heyApiClient).get< + GetContractSignaturesResponses, + GetContractSignaturesErrors, + ThrowOnError + >({ + security: [ { name: "x-secret-key", type: "apiKey", }, + ], + url: "/v1/contracts/{chainId}/{address}/signatures", + ...options, + }); +}; + +/** + * Get Transaction + * Retrieves detailed information about a specific transaction using its unique identifier. Returns comprehensive transaction data including execution status, blockchain details, and any associated metadata. + * + * **Authentication**: Pass `x-client-id` header for frontend usage from allowlisted origins or `x-secret-key` for backend usage. + */ +export const getTransactionById = ( + options: Options, +) => { + return (options.client ?? _heyApiClient).get< + GetTransactionByIdResponses, + GetTransactionByIdErrors, + ThrowOnError + >({ + security: [ { - scheme: "bearer", - type: "http", + name: "x-client-id", + type: "apiKey", }, ], - url: "/v1/wallets/login/siwe/verify", + url: "/v1/transactions/{transactionId}", ...options, - headers: { - "Content-Type": "application/json", - ...options?.headers, - }, }); }; @@ -808,14 +930,6 @@ export const listTransactions = ( name: "x-client-id", type: "apiKey", }, - { - name: "x-secret-key", - type: "apiKey", - }, - { - scheme: "bearer", - type: "http", - }, ], url: "/v1/transactions", ...options, @@ -824,7 +938,7 @@ export const listTransactions = ( /** * Send Transactions - * Submits a blockchain transaction. Supports three types of transactions: native token transfers, encoded transactions with custom data, and smart contract method calls. The transaction type is determined by the 'type' field in the request body. + * Submits pre-encoded blockchain transactions with custom data payloads. This endpoint is for low-level transaction submission where you have already encoded the transaction data. For smart contract method calls, use /v1/contracts/write. For native token transfers, use /v1/wallets/send. * * **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 ` headers. */ @@ -838,17 +952,13 @@ export const sendTransactions = ( >({ security: [ { - name: "x-client-id", - type: "apiKey", + scheme: "bearer", + type: "http", }, { - name: "x-secret-key", + name: "x-client-id", type: "apiKey", }, - { - scheme: "bearer", - type: "http", - }, ], url: "/v1/transactions", ...options, @@ -860,50 +970,48 @@ export const sendTransactions = ( }; /** - * Get Transaction by ID - * Retrieves detailed information about a specific transaction using its unique identifier. Returns comprehensive transaction data including execution status, blockchain details, and any associated metadata. + * Create 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. * - * **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. */ -export const getTransactionById = ( - options: Options, +export const createPayment = ( + options?: Options, ) => { - return (options.client ?? _heyApiClient).get< - GetTransactionByIdResponses, - GetTransactionByIdErrors, + return (options?.client ?? _heyApiClient).post< + CreatePaymentResponses, + CreatePaymentErrors, ThrowOnError >({ security: [ { - name: "x-client-id", - type: "apiKey", + scheme: "bearer", + type: "http", }, { - name: "x-secret-key", + name: "x-client-id", type: "apiKey", }, - { - scheme: "bearer", - type: "http", - }, ], - url: "/v1/transactions/{transactionId}", + url: "/v1/payments", ...options, + headers: { + "Content-Type": "application/json", + ...options?.headers, + }, }); }; /** - * Sign Message - * Signs an arbitrary message using a connected wallet. This endpoint supports both text and hexadecimal message formats. The signing is performed using thirdweb Engine with smart account support for gasless transactions. - * - * **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 ` headers. + * Get Payment History + * Get payment history for a specific payment link */ -export const signMessage = ( - options?: Options, +export const getPaymentHistory = ( + options: Options, ) => { - return (options?.client ?? _heyApiClient).post< - SignMessageResponses, - SignMessageErrors, + return (options.client ?? _heyApiClient).get< + GetPaymentHistoryResponses, + GetPaymentHistoryErrors, ThrowOnError >({ security: [ @@ -911,53 +1019,101 @@ export const signMessage = ( name: "x-client-id", type: "apiKey", }, - { - name: "x-secret-key", - type: "apiKey", - }, + ], + url: "/v1/payments/{id}", + ...options, + }); +}; + +/** + * Complete Payment + * 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. + */ +export const paymentsPurchase = ( + options: Options, +) => { + return (options.client ?? _heyApiClient).post< + PaymentsPurchaseResponses, + PaymentsPurchaseErrors, + ThrowOnError + >({ + security: [ { scheme: "bearer", type: "http", }, + { + name: "x-client-id", + type: "apiKey", + }, ], - url: "/v1/sign/message", + url: "/v1/payments/{id}", ...options, headers: { "Content-Type": "application/json", - ...options?.headers, + ...options.headers, }, }); }; /** - * Sign Typed Data - * Signs structured data according to the EIP-712 standard. This is commonly used for secure message signing in DeFi protocols, NFT marketplaces, and other dApps that require structured data verification. The typed data includes domain separation and type definitions for enhanced security. + * List Tokens + * Lists or search existing tokens based on the provided filters. Supports querying by chain ID, token address, symbol, and/or name. * - * **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 ` headers. + * + * + * **Authentication**: Pass `x-client-id` header for frontend usage from allowlisted origins or `x-secret-key` for backend usage. */ -export const signTypedData = ( - options?: Options, +export const listTokens = ( + options?: Options, ) => { - return (options?.client ?? _heyApiClient).post< - SignTypedDataResponses, - SignTypedDataErrors, + return (options?.client ?? _heyApiClient).get< + ListTokensResponses, + ListTokensErrors, ThrowOnError >({ security: [ { - name: "x-client-id", - type: "apiKey", + scheme: "bearer", + type: "http", }, { - name: "x-secret-key", + name: "x-client-id", type: "apiKey", }, + ], + url: "/v1/tokens", + ...options, + }); +}; + +/** + * Create Token + * Create a new ERC20 token with the provided metadata and starting price. The token is immediately available for purchase using thirdweb Payments. + * + * **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 ` headers. + */ +export const createToken = ( + options?: Options, +) => { + return (options?.client ?? _heyApiClient).post< + CreateTokenResponses, + CreateTokenErrors, + ThrowOnError + >({ + security: [ { scheme: "bearer", type: "http", }, + { + name: "x-client-id", + type: "apiKey", + }, ], - url: "/v1/sign/typed-data", + url: "/v1/tokens", ...options, headers: { "Content-Type": "application/json", @@ -967,17 +1123,17 @@ export const signTypedData = ( }; /** - * Buy Token - * Purchase tokens using a USD amount. The system will automatically handle wallet creation if needed, check your wallet balance, and execute the optimal cross-chain route to get the tokens you want. + * Get Owners + * Retrieves a paginated list of owners for a given ERC-20 token contract on a specific chain. * - * **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 ` headers. + * **Authentication**: Pass `x-client-id` header for frontend usage from allowlisted origins or `x-secret-key` for backend usage. */ -export const buyTokenWithUsd = ( - options?: Options, +export const getTokenOwners = ( + options: Options, ) => { - return (options?.client ?? _heyApiClient).post< - BuyTokenWithUsdResponses, - BuyTokenWithUsdErrors, + return (options.client ?? _heyApiClient).get< + GetTokenOwnersResponses, + GetTokenOwnersErrors, ThrowOnError >({ security: [ @@ -985,16 +1141,37 @@ export const buyTokenWithUsd = ( name: "x-client-id", type: "apiKey", }, - { - name: "x-secret-key", - type: "apiKey", - }, + ], + url: "/v1/tokens/{chainId}/{address}/owners", + ...options, + }); +}; + +/** + * Swap or Bridge Tokens + * 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**: 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 ` headers. + */ +export const bridgeSwap = ( + options?: Options, +) => { + return (options?.client ?? _heyApiClient).post< + BridgeSwapResponses, + BridgeSwapErrors, + ThrowOnError + >({ + security: [ { scheme: "bearer", type: "http", }, + { + name: "x-client-id", + type: "apiKey", + }, ], - url: "/v1/tokens/buy", + url: "/v1/bridge/swap", ...options, headers: { "Content-Type": "application/json", @@ -1004,17 +1181,21 @@ export const buyTokenWithUsd = ( }; /** - * Sell Token - * Sell tokens for a USD amount. The system will automatically handle the optimal cross-chain route to convert your tokens to USD. + * Chat + * Thirdweb AI chat completion API (BETA). * - * **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 ` headers. + * 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. */ -export const sellTokenForUsd = ( - options?: Options, +export const chat = ( + options?: Options, ) => { return (options?.client ?? _heyApiClient).post< - SellTokenForUsdResponses, - SellTokenForUsdErrors, + ChatResponses, + unknown, ThrowOnError >({ security: [ @@ -1022,16 +1203,8 @@ export const sellTokenForUsd = ( name: "x-client-id", type: "apiKey", }, - { - name: "x-secret-key", - type: "apiKey", - }, - { - scheme: "bearer", - type: "http", - }, ], - url: "/v1/tokens/sell", + url: "/ai/chat", ...options, headers: { "Content-Type": "application/json", @@ -1041,34 +1214,36 @@ export const sellTokenForUsd = ( }; /** - * Transfer Token - * Transfer tokens worth a USD amount to another wallet address. The system will calculate the required token amount based on current prices and execute the transfer. + * MCP Server + * 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**: 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 ` headers. + * Add this MCP server to any MCP client: + * + * ```json + * { + * "mcpServers": { + * "thirdweb-api": { + * "url": "https://api.thirdweb.com/mcp?secretKey=YOUR_SECRET_KEY_HERE" + * } + * } + * } + * ``` */ -export const transferTokenWithUsd = ( - options?: Options, +export const mcpServer = ( + options?: Options, ) => { return (options?.client ?? _heyApiClient).post< - TransferTokenWithUsdResponses, - TransferTokenWithUsdErrors, + McpServerResponses, + unknown, ThrowOnError >({ security: [ - { - name: "x-client-id", - type: "apiKey", - }, { name: "x-secret-key", type: "apiKey", }, - { - scheme: "bearer", - type: "http", - }, ], - url: "/v1/tokens/transfer", + url: "/mcp", ...options, headers: { "Content-Type": "application/json", @@ -1076,3 +1251,20 @@ export const transferTokenWithUsd = ( }, }); }; + +/** + * llms.txt + * The full openAPI reference for the thirdweb API in LLMs.txt format. Useful for AI assistants to understand the API and its capabilities. No authentication is required. Copy paste the contents of [https://api.thirdweb.com/llms.txt](https://api.thirdweb.com/llms.txt) into your source code to make your AI assistant understand the API and its capabilities. + */ +export const llmsTxt = ( + options?: Options, +) => { + return (options?.client ?? _heyApiClient).get< + LlmsTxtResponses, + unknown, + ThrowOnError + >({ + url: "/llms.txt", + ...options, + }); +}; diff --git a/packages/api/src/client/types.gen.ts b/packages/api/src/client/types.gen.ts index 14304854b9a..b6112d8deb7 100644 --- a/packages/api/src/client/types.gen.ts +++ b/packages/api/src/client/types.gen.ts @@ -1,749 +1,1101 @@ // This file is auto-generated by @hey-api/openapi-ts -export type ListContractsData = { - body?: never; +export type InitiateAuthenticationData = { + /** + * Authentication Initiate Request + * Request to initiate authentication flow. Choose one of the supported authentication methods: sms, email, oauth, passkey, or siwe. The required fields depend on the authentication method selected. + */ + body?: + | { + /** + * Authentication method: SMS + */ + method: "sms"; + /** + * Phone number in E.164 format (e.g., +1234567890) + */ + phone: string; + } + | { + /** + * Authentication method: Email + */ + method: "email"; + /** + * Email address for verification code + */ + email: string; + } + | { + /** + * Authentication method: OAuth + */ + method: "oauth"; + /** + * Social login provider + */ + provider: + | "google" + | "apple" + | "facebook" + | "discord" + | "farcaster" + | "telegram" + | "line" + | "x" + | "coinbase" + | "github" + | "twitch" + | "steam" + | "tiktok"; + /** + * Custom redirect URL after OAuth completion + */ + redirectUrl?: string; + } + | { + /** + * Authentication method: Passkey + */ + method: "passkey"; + /** + * Whether to create a new passkey or use existing one + */ + type: "sign-up" | "sign-in"; + /** + * Username for passkey (optional, for identification) + */ + username?: string; + } + | { + /** + * Authentication method: Sign-In with Ethereum + */ + method: "siwe"; + /** + * Ethereum wallet address for SIWE + */ + address: string; + /** + * Chain ID for SIWE (defaults to 1) + */ + chainId?: number; + }; path?: never; - query?: { - /** - * Whether to include the contract ABI (Application Binary Interface) for each contract. When true, fetches the ABI from the thirdweb contract service and returns it in an optional 'abi' array within each contract. - */ - includeAbi?: string; - /** - * Whether to include contract metadata from the thirdweb contract metadata service. When true, fetches additional metadata for each contract and returns it in an optional 'metadata' object within each contract. - */ - includeMetadata?: string; - /** - * The number of contracts to return (default: 20, max: 100). - */ - limit?: number; - /** - * The page number for pagination (default: 1). - */ - page?: number; - }; - url: "/v1/contracts"; + query?: never; + url: "/v1/auth/initiate"; }; -export type ListContractsErrors = { +export type InitiateAuthenticationErrors = { /** - * Invalid request parameters + * Invalid request - Check your method and parameters */ 400: unknown; /** - * Authentication required. The request must include a valid `x-secret-key` header for backend authentication. - */ - 401: unknown; - /** - * Rate limit exceeded + * Rate limit exceeded - Please wait before trying again */ 429: unknown; +}; + +export type InitiateAuthenticationResponses = { /** - * Internal server error + * Authentication Initiate Response + * Response from authentication initiation. Contains method-specific data needed to complete authentication. */ - 500: unknown; + 200: + | { + /** + * Authentication method: SMS + */ + method: "sms"; + /** + * Whether the SMS code was sent successfully + */ + success: boolean; + } + | { + /** + * Authentication method: Email + */ + method: "email"; + /** + * Whether the email code was sent successfully + */ + success: boolean; + } + | { + /** + * Authentication method: OAuth + */ + method: "oauth"; + /** + * URL to redirect user for OAuth authentication + */ + redirectUrl: string; + } + | { + /** + * Authentication method: Passkey + */ + method: "passkey"; + /** + * Server verification ID for passkey + */ + serverVerificationId: string; + /** + * Base64-encoded WebAuthn challenge + */ + challenge: string; + /** + * Challenge type (sign-up or sign-in) + */ + type: string; + } + | { + /** + * Authentication method: Sign-In with Ethereum + */ + method: "siwe"; + /** + * SIWE message string to be signed + */ + payload: string; + }; }; -export type ListContractsResponses = { +export type InitiateAuthenticationResponse = + InitiateAuthenticationResponses[keyof InitiateAuthenticationResponses]; + +export type CompleteAuthenticationData = { /** - * Successfully retrieved list of contracts + * Authentication Complete Request + * Request to complete authentication flow. Choose the same method used in initiate: sms, email, oauth, passkey, siwe, guest, or custom. The required fields depend on the authentication method. */ - 200: { - result: { - /** - * Array of contracts imported by the client. - */ - contracts: Array<{ + body?: + | { /** - * The contract ABI (Application Binary Interface) as an array of objects. Contains function definitions, event signatures, constructor parameters, error definitions, and other contract interface specifications. Only present when includeAbi=true. + * Authentication method: SMS */ - abi?: Array<{ - [key: string]: unknown; - }>; + method: "sms"; /** - * The contract address. + * Phone number that received the code */ - address: string; + phone: string; /** - * The chain ID where the contract is deployed. + * Verification code received via SMS */ - chainId: string; + code: string; + } + | { /** - * The date when the contract was deployed. + * Authentication method: Email */ - deployedAt?: string; + method: "email"; /** - * The contract ID. + * Email address that received the code */ - id?: string; + email: string; /** - * The date when the contract was imported to the dashboard. + * Verification code received via email */ - importedAt: string; + code: string; + } + | { /** - * Additional contract metadata from the thirdweb contract metadata service. Only present when includeMetadata=true. Contains compilation details, ABI information, and Solidity metadata. + * Authentication method: Passkey */ - metadata?: { - /** - * The chain ID where the contract is deployed. - */ - chainId: number; - /** - * Array of compilation target paths. - */ - compilationTarget?: Array; - /** - * The contract address. - */ - contractAddress: string; - /** - * The implementation address for proxy contracts. - */ - implementationAddress?: string; - /** - * Whether the ABI is a composite of multiple contracts. - */ - isCompositeAbi?: boolean; - /** - * Whether the ABI is partial or complete. - */ - isPartialAbi?: boolean; + method: "passkey"; + /** + * Passkey operation type + */ + type: "sign-up" | "sign-in"; + /** + * Base64-encoded authenticator data + */ + authenticatorData: string; + /** + * Base64-encoded credential ID + */ + credentialId: string; + /** + * Server verification ID from initiate response + */ + serverVerificationId: string; + /** + * Base64-encoded client data JSON + */ + clientData: string; + /** + * Base64-encoded signature (for sign-in) + */ + signature?: string; + /** + * Origin of the request + */ + origin?: string; + /** + * Relying party identifier + */ + rpId?: string; + /** + * Username for the passkey + */ + username?: string; + /** + * Credential data for passkey registration + */ + credential?: { /** - * Solidity metadata object as defined in the Solidity documentation. Contains compiler settings, sources, and other compilation metadata. + * Public key for the credential */ - metadata?: { - [key: string]: unknown; - }; + publicKey: string; /** - * The strategy used to retrieve the metadata. + * Algorithm used for the credential */ - strategy?: string; + algorithm: "RS256" | "ES256"; }; + } + | { /** - * The contract name, if available. + * Authentication method: Sign-In with Ethereum */ - name?: string; + method: "siwe"; /** - * The contract symbol, if available. + * Hex-encoded signed SIWE message */ - symbol?: string; + signature: string; /** - * The contract type (e.g., ERC20, ERC721, etc.). + * The original SIWE payload that was signed */ - type?: string; - }>; - pagination: { + payload: string; + } + | { /** - * Whether there are more items available + * Authentication method: Custom */ - hasMore?: boolean; + method: "custom"; /** - * Number of items per page + * Custom authentication type */ - limit: number; + type: "jwt" | "auth-payload"; /** - * Current page number + * JWT token for OIDC authentication */ - page: number; + jwt?: unknown; /** - * Total number of items available + * Custom authentication payload */ - totalCount?: number; - }; - }; - }; + payload?: unknown; + } + | { + /** + * Authentication method: Guest + */ + method: "guest"; + /** + * Optional guest session ID - if not provided, a random one will be generated with no persistence guarantees. + */ + sessionId?: string; + }; + path?: never; + query?: never; + url: "/v1/auth/complete"; }; -export type ListContractsResponse = - ListContractsResponses[keyof ListContractsResponses]; +export type CompleteAuthenticationErrors = { + /** + * Invalid credentials or request - Check your challenge ID and verification data + */ + 400: unknown; + /** + * Rate limit exceeded - Please wait before trying again + */ + 429: unknown; +}; -export type DeployContractData = { - body?: { +export type CompleteAuthenticationResponses = { + /** + * Successful authentication response. Returns wallet address plus authentication tokens. + */ + 200: { /** - * The blockchain network identifier. Common values include: 1 (Ethereum), 8453 (Base), 137 (Polygon), 56 (BSC), 43114 (Avalanche), 42161 (Arbitrum), 10 (Optimism). + * Whether this is a newly created user/wallet */ - chainId: number; + isNewUser: boolean; /** - * Object containing constructor parameters for the contract deployment (e.g., { param1: 'value1', param2: 123 }). + * JWT authentication token for API access */ - constructorParams?: { - [key: string]: unknown; - }; + token: string; /** - * The URL to the contract source from thirdweb.com (e.g., https://thirdweb.com/thirdweb.eth/TokenERC20). Version suffixes will be automatically stripped. + * Type of authentication completed */ - contractUrl: string; + type: string; /** - * The wallet address that will deploy the contract. + * The wallet address */ - from: string; + walletAddress: string; + }; +}; + +export type CompleteAuthenticationResponse = + CompleteAuthenticationResponses[keyof CompleteAuthenticationResponses]; + +export type SocialAuthenticationData = { + body?: never; + path?: never; + query: { /** - * Optional salt value for deterministic contract deployment. + * The OAuth provider to use */ - salt?: string; + provider: + | "google" + | "apple" + | "facebook" + | "discord" + | "farcaster" + | "telegram" + | "line" + | "x" + | "coinbase" + | "github" + | "twitch" + | "steam" + | "tiktok"; + /** + * URL to redirect the user to after OAuth completion + */ + redirectUrl: string; + /** + * Client ID (alternative to x-client-id header for standard OAuth flows) + */ + clientId?: string; }; - path?: never; - query?: never; - url: "/v1/contracts"; + url: "/v1/auth/social"; }; -export type DeployContractErrors = { +export type SocialAuthenticationErrors = { /** * Invalid request parameters */ 400: unknown; +}; + +export type GetMyWalletData = { + body?: never; + path?: never; + query?: never; + url: "/v1/wallets/me"; +}; + +export type GetMyWalletErrors = { /** - * Authentication required. The request must include a valid `x-secret-key` header for backend authentication. + * Authentication required. The request must include a valid `Authorization: Bearer ` header. */ 401: unknown; /** - * Rate limit exceeded + * Wallet not found. The authenticated user does not exist in the system. */ - 429: unknown; + 404: unknown; /** - * Internal server error + * Internal server error. This may occur due to service unavailability or unexpected server errors. */ 500: unknown; }; -export type DeployContractResponses = { +export type GetMyWalletResponses = { /** - * Contract deployed successfully + * Wallet retrieved successfully. Returns comprehensive user information including wallet addresses, public key, and linked wallets. */ 200: { result: { /** - * The deployed contract address. - */ - address: string; - /** - * The chain ID where the contract was deployed. - */ - chainId: number; - /** - * The unique identifier for the transaction that deployed the contract. Will not be returned if the contract was already deployed at the predicted address. + * The EOA (Externally Owned Wallet) address of the wallet. This is the traditional wallet address. */ - transactionId?: string; - }; - }; -}; - -export type DeployContractResponse = - DeployContractResponses[keyof DeployContractResponses]; - -export type ReadContractData = { - body?: { - /** - * Array of contract method calls to execute. Each call specifies a contract address, method signature, and optional parameters. - */ - calls: Array<{ + address?: string; /** - * The smart contract address. Must be a valid Ethereum-compatible address (42 characters, starting with 0x). + * The date and time the wallet was created */ - contractAddress: string; + createdAt?: string; /** - * The contract function signature to call (e.g., 'function approve(address spender, uint256 amount)' or `function balanceOf(address)`). Must start with 'function' followed by the function name and parameters as defined in the contract ABI. + * AuthenticationProviderDetail + * Authentication provider details with type-based discrimination */ - method: string; + profiles: Array< + | { + email: string; + emailVerified: boolean; + familyName?: string; + givenName?: string; + hd: string; + id: string; + locale: string; + name?: string; + picture: string; + type: "google"; + } + | { + email?: string; + firstName?: string; + id: string; + lastName?: string; + name?: string; + picture?: string; + type: "facebook"; + } + | { + email?: string; + emailVerified: boolean; + id: string; + isPrivateEmail: boolean; + type: "apple"; + } + | { + avatar?: string; + id: string; + name?: string; + type: "github"; + username: string; + } + | { + avatar: string; + email?: string; + emailVerified: boolean; + id: string; + type: "discord"; + username: string; + } + | { + avatar?: string; + id: string; + name: string; + type: "coinbase"; + } + | { + id: string; + name: string; + type: "x"; + username: string; + profileImageUrl?: string; + } + | { + id: string; + displayName: string; + avatarUrl: string; + unionId?: string; + type: "tiktok"; + } + | { + avatar?: string; + id: string; + metadata: { + avatar: { + large?: string; + medium?: string; + small?: string; + }; + personaname?: string; + profileurl?: string; + realname?: string; + }; + type: "steam"; + username?: string; + } + | { + firstName?: string; + id: string; + lastName?: string; + picture?: string; + type: "telegram"; + username?: string; + } + | { + avatar?: string; + description?: string; + email?: string; + id: string; + type: "twitch"; + username: string; + } + | { + avatar?: string; + id: string; + type: "line"; + username?: string; + } + | { + fid: string; + id: string; + type: "farcaster"; + walletAddress?: string; + } + | { + algorithm: string; + credentialId: string; + publicKey: string; + type: "passkey"; + } + | { + email: string; + id: string; + type: "email"; + } + | { + id: string; + pregeneratedIdentifier: string; + type: "pre_generation"; + } + | { + id: string; + phone: string; + type: "phone"; + } + | { + id: string; + type: "siwe"; + walletAddress: string; + } + | { + id: string; + type: "guest"; + } + | { + id: string; + type: "backend"; + } + | { + identifier: string; + type: "server"; + } + | { + authProviderId?: string; + email?: string; + id: string; + phone?: string; + type: "custom_jwt"; + walletAddress?: string; + } + | { + authProviderId?: string; + email?: string; + id: string; + phone?: string; + type: "custom_auth_endpoint"; + walletAddress?: string; + } + >; /** - * Array of parameters to pass to the contract method, in the correct order and format. + * The smart wallet address with EIP-4337 support. This address enables gasless transactions and advanced wallet features. */ - params?: Array; + smartWalletAddress?: string; /** - * Amount of native token to send with the transaction in wei. Required for payable methods. + * The wallet's public key in hexadecimal format. Useful for peer-to-peer encryption and cryptographic operations. */ - value?: string; - }>; - /** - * The blockchain network identifier. Common values include: 1 (Ethereum), 8453 (Base), 137 (Polygon), 56 (BSC), 43114 (Avalanche), 42161 (Arbitrum), 10 (Optimism). - */ - chainId: number; + publicKey?: string; + }; }; +}; + +export type GetMyWalletResponse = + GetMyWalletResponses[keyof GetMyWalletResponses]; + +export type ListUserWalletsData = { + body?: never; path?: never; - query?: never; - url: "/v1/contracts/read"; + query?: { + limit?: number; + page?: number; + email?: string; + phone?: string; + address?: string; + externalWalletAddress?: string; + id?: string; + }; + url: "/v1/wallets/user"; }; -export type ReadContractErrors = { - /** - * Invalid request parameters. This occurs when the chainId is not supported, contract addresses are invalid, function signatures are malformed, or the calls array is empty. - */ - 400: unknown; +export type ListUserWalletsErrors = { /** - * Authentication required. The request must include a valid `x-client-id` header for frontend usage or x-secret-key for backend usage. + * Authentication required. The request must include a valid `x-secret-key` header for backend authentication. */ 401: unknown; /** - * Internal server error. This may occur due to engine connectivity issues, RPC node unavailability, or unexpected server errors. + * Internal server error. This may occur due to service unavailability or unexpected server errors. */ 500: unknown; }; -export type ReadContractResponses = { +export type ListUserWalletsResponses = { /** - * Contract read operations completed successfully. Returns an array of results corresponding to each input call, including both successful and failed operations. + * Returns a list of user wallet addresses, smart wallet addresses, and auth details. */ 200: { - /** - * Array of results corresponding to each contract read call. Results are returned in the same order as the input calls. - */ - result: Array<{ - /** - * The result of the contract read operation. The type and format depend on the method's return value as defined in the contract ABI. - */ - data?: unknown; + result: { /** - * Error message if the contract read operation failed. + * Pagination information */ - error?: string; + pagination: { + /** + * Whether there are more items available + */ + hasMore?: boolean; + /** + * Number of items per page + */ + limit?: number; + /** + * Current page number + */ + page?: number; + /** + * Total number of items available + */ + totalCount?: number; + }; /** - * Indicates whether the contract read operation was successful. + * Array of user wallets */ - success: boolean; - }>; - }; -}; - -export type ReadContractResponse = - ReadContractResponses[keyof ReadContractResponses]; - -export type GetContractTransactionsData = { - body?: never; - path: { - /** - * The smart contract address. Must be a valid Ethereum-compatible address (42 characters, starting with 0x). - */ - address: string; - }; - query: { - /** - * Chain ID(s) to request transaction data for. You can specify multiple chain IDs by repeating the parameter, up to a maximum of 50. Example: ?chainId=1&chainId=137 - */ - chainId: Array; - /** - * Whether to enable ABI decoding of transaction data. When true, returns decoded function calls if ABI is available. - */ - decode?: boolean; - /** - * The number of transactions to return per chain (default: 20, max: 500). - */ - limit?: number; - /** - * The page number for pagination (default: 0, max: 20). - */ - page?: number; - /** - * Sort order - ascending or descending (default: desc). - */ - sortOrder?: "asc" | "desc"; - /** - * Start time for filtering transactions (Unix timestamp). Default is 3 months ago. - */ - startTime?: number; - }; - url: "/v1/contracts/{address}/transactions"; -}; - -export type GetContractTransactionsErrors = { - /** - * Invalid request parameters. This occurs when the contract address format is invalid, chainId array is empty or exceeds the maximum limit of 50, or pagination parameters are out of range. - */ - 400: unknown; - /** - * Authentication required. The request must include a valid `x-client-id` header for frontend usage or x-secret-key for backend usage. - */ - 401: unknown; - /** - * Contract not found or no transactions available for the specified contract address on the given blockchain networks. - */ - 404: unknown; - /** - * Internal server error. This may occur due to network connectivity issues, external service unavailability, or unexpected server errors. - */ - 500: unknown; -}; - -export type GetContractTransactionsResponses = { - /** - * Contract transactions retrieved successfully. Returns transaction data with metadata including pagination information and chain details. When decode=true, includes decoded function calls if ABI is available. - */ - 200: { - result: { - /** - * Array of contract transactions. - */ - data: Array<{ - /** - * The hash of the block containing this transaction. - */ - blockHash: string; - /** - * The block number containing this transaction. - */ - blockNumber: number; - /** - * The timestamp of the block (Unix timestamp). - */ - blockTimestamp: number; - /** - * The chain ID where the transaction occurred. - */ - chainId: string; - /** - * Contract address created if this was a contract creation transaction. - */ - contractAddress?: string; - /** - * Total gas used by all transactions in this block up to and including this one. - */ - cumulativeGasUsed?: number; - /** - * The transaction input data. - */ - data: string; - /** - * Decoded transaction data (only present when decode=true and ABI is available). - */ - decoded?: { - /** - * Object containing decoded function parameters. - */ - inputs: { - [key: string]: unknown; - }; - /** - * The function name. - */ - name: string; - /** - * The function signature. - */ - signature: string; - }; - /** - * The effective gas price paid (in wei as string). - */ - effectiveGasPrice?: string; - /** - * The address that initiated the transaction. - */ - fromAddress: string; - /** - * The function selector (first 4 bytes of the transaction data). - */ - functionSelector: string; - /** - * The gas limit for the transaction. - */ - gas: number; - /** - * The gas price used for the transaction (in wei as string). - */ - gasPrice: string; - /** - * The amount of gas used by the transaction. - */ - gasUsed?: number; - /** - * The transaction hash. - */ - hash: string; - /** - * Maximum fee per gas (EIP-1559). - */ - maxFeePerGas?: string; - /** - * Maximum priority fee per gas (EIP-1559). - */ - maxPriorityFeePerGas?: string; - /** - * The transaction nonce. - */ - nonce: number; - /** - * The transaction status (1 for success, 0 for failure). - */ - status: number; - /** - * The address that received the transaction. - */ - toAddress: string; - /** - * The index of the transaction within the block. - */ - transactionIndex: number; + wallets: Array<{ /** - * The transaction type (0=legacy, 1=EIP-2930, 2=EIP-1559). + * The EOA (Externally Owned Wallet) address of the wallet. This is the traditional wallet address. */ - transactionType?: number; + address?: string; /** - * The value transferred in the transaction (in wei as string). - */ - value: string; - }>; - pagination: { - /** - * Whether there are more items available + * The date and time the wallet was created */ - hasMore?: boolean; + createdAt?: string; /** - * Number of items per page + * AuthenticationProviderDetail + * Authentication provider details with type-based discrimination */ - limit: number; + profiles: Array< + | { + email: string; + emailVerified: boolean; + familyName?: string; + givenName?: string; + hd: string; + id: string; + locale: string; + name?: string; + picture: string; + type: "google"; + } + | { + email?: string; + firstName?: string; + id: string; + lastName?: string; + name?: string; + picture?: string; + type: "facebook"; + } + | { + email?: string; + emailVerified: boolean; + id: string; + isPrivateEmail: boolean; + type: "apple"; + } + | { + avatar?: string; + id: string; + name?: string; + type: "github"; + username: string; + } + | { + avatar: string; + email?: string; + emailVerified: boolean; + id: string; + type: "discord"; + username: string; + } + | { + avatar?: string; + id: string; + name: string; + type: "coinbase"; + } + | { + id: string; + name: string; + type: "x"; + username: string; + profileImageUrl?: string; + } + | { + id: string; + displayName: string; + avatarUrl: string; + unionId?: string; + type: "tiktok"; + } + | { + avatar?: string; + id: string; + metadata: { + avatar: { + large?: string; + medium?: string; + small?: string; + }; + personaname?: string; + profileurl?: string; + realname?: string; + }; + type: "steam"; + username?: string; + } + | { + firstName?: string; + id: string; + lastName?: string; + picture?: string; + type: "telegram"; + username?: string; + } + | { + avatar?: string; + description?: string; + email?: string; + id: string; + type: "twitch"; + username: string; + } + | { + avatar?: string; + id: string; + type: "line"; + username?: string; + } + | { + fid: string; + id: string; + type: "farcaster"; + walletAddress?: string; + } + | { + algorithm: string; + credentialId: string; + publicKey: string; + type: "passkey"; + } + | { + email: string; + id: string; + type: "email"; + } + | { + id: string; + pregeneratedIdentifier: string; + type: "pre_generation"; + } + | { + id: string; + phone: string; + type: "phone"; + } + | { + id: string; + type: "siwe"; + walletAddress: string; + } + | { + id: string; + type: "guest"; + } + | { + id: string; + type: "backend"; + } + | { + identifier: string; + type: "server"; + } + | { + authProviderId?: string; + email?: string; + id: string; + phone?: string; + type: "custom_jwt"; + walletAddress?: string; + } + | { + authProviderId?: string; + email?: string; + id: string; + phone?: string; + type: "custom_auth_endpoint"; + walletAddress?: string; + } + >; /** - * Current page number + * The smart wallet address with EIP-4337 support. This address enables gasless transactions and advanced wallet features. */ - page: number; + smartWalletAddress?: string; /** - * Total number of items available + * The wallet's public key in hexadecimal format. Useful for peer-to-peer encryption and cryptographic operations. */ - totalCount?: number; - }; + publicKey?: string; + }>; }; }; }; -export type GetContractTransactionsResponse = - GetContractTransactionsResponses[keyof GetContractTransactionsResponses]; +export type ListUserWalletsResponse = + ListUserWalletsResponses[keyof ListUserWalletsResponses]; -export type GetContractEventsData = { - body?: never; - path: { - /** - * The smart contract address. Must be a valid Ethereum-compatible address (42 characters, starting with 0x). - */ - address: string; - }; - query: { - /** - * Chain ID(s) to request event data for. You can specify multiple chain IDs by repeating the parameter, up to a maximum of 50. Example: ?chainId=1&chainId=137 - */ - chainId: Array; - /** - * Whether to enable ABI decoding of event data. When true, returns decoded event parameters if ABI is available. - */ - decode?: boolean; - /** - * Maximum number of events to return per chain. Must be between 1 and 500. Default is 20. - */ - limit?: number; - /** - * Page number for pagination (0-based). Must be between 0 and 20. Default is 0. - */ - page?: number; - /** - * Sort order for the results. Always sorts by block_number. 'desc' for newest first, 'asc' for oldest first. Default is 'desc'. - */ - sortOrder?: "asc" | "desc"; +export type CreateUserWalletData = { + /** + * Request body for pre-generating a wallet + */ + body?: { + type: + | "google" + | "apple" + | "facebook" + | "discord" + | "email" + | "phone" + | "custom_auth_endpoint" + | "custom_jwt" + | "siwe"; /** - * Start time for filtering events (Unix timestamp). Default is 3 months ago. + * A valid Ethereum address (0x-prefixed hex string) or ENS name (e.g., vitalik.eth). */ - startTime?: number; + walletAddress?: string; + email?: string; + phone?: string; + userId?: string; }; - url: "/v1/contracts/{address}/events"; + path?: never; + query?: never; + url: "/v1/wallets/user"; }; -export type GetContractEventsErrors = { +export type CreateUserWalletErrors = { /** - * Invalid request parameters. This occurs when the contract address format is invalid, chainId array is empty or exceeds the maximum limit of 50, or pagination parameters are out of range. + * Invalid request. This may occur due to missing required fields based on the authentication strategy, invalid strategy, or malformed request data. */ 400: unknown; /** - * Authentication required. The request must include a valid `x-client-id` header for frontend usage or x-secret-key for backend usage. + * Authentication required. The request must include a valid `x-secret-key` header for backend authentication. */ 401: unknown; /** - * Contract not found or no events available for the specified contract address on the given blockchain networks. - */ - 404: unknown; - /** - * Internal server error. This may occur due to network connectivity issues, external service unavailability, or unexpected server errors. + * Internal server error. This may occur due to service unavailability or unexpected server errors. */ 500: unknown; }; -export type GetContractEventsResponses = { +export type CreateUserWalletResponses = { /** - * Contract events retrieved successfully. Returns event data with metadata including pagination information and chain details. When decode=true, includes decoded event parameters if ABI is available. + * Successfully created a user wallet with wallet. */ 200: { result: { /** - * Array of contract events. - */ - events: Array<{ - /** - * The contract address that emitted the event. - */ - address: string; - /** - * The hash of the block containing this event. - */ - blockHash: string; - /** - * The block number where the event was emitted. - */ - blockNumber: number; - /** - * The timestamp of the block (Unix timestamp). - */ - blockTimestamp: number; - /** - * The chain ID where the event occurred. - */ - chainId: string; - /** - * The non-indexed event data as a hex string. - */ - data: string; - /** - * Decoded event data (only present when decode=true and ABI is available). - */ - decoded?: { - /** - * The event name. - */ - name: string; - /** - * Object containing decoded parameters. - */ - params: { - [key: string]: unknown; - }; - /** - * The event signature. - */ - signature: string; - }; - /** - * The index of the log within the transaction. - */ - logIndex: number; - /** - * Array of indexed event topics (including event signature). - */ - topics: Array; - /** - * The hash of the transaction containing this event. - */ - transactionHash: string; - /** - * The index of the transaction within the block. - */ - transactionIndex: number; - }>; - pagination: { - /** - * Whether there are more items available - */ - hasMore?: boolean; - /** - * Number of items per page - */ - limit: number; - /** - * Current page number - */ - page: number; - /** - * Total number of items available - */ - totalCount?: number; - }; - }; - }; -}; - -export type GetContractEventsResponse = - GetContractEventsResponses[keyof GetContractEventsResponses]; - -export type WriteContractData = { - body?: { - /** - * Array of contract method calls to execute. Each call specifies a contract address, method signature, and optional parameters. - */ - calls: Array<{ - /** - * The smart contract address. Must be a valid Ethereum-compatible address (42 characters, starting with 0x). + * The EOA (Externally Owned Wallet) address of the wallet. This is the traditional wallet address. */ - contractAddress: string; + address?: string; /** - * The contract function signature to call (e.g., 'function approve(address spender, uint256 amount)' or `function balanceOf(address)`). Must start with 'function' followed by the function name and parameters as defined in the contract ABI. + * The date and time the wallet was created */ - method: string; + createdAt?: string; /** - * Array of parameters to pass to the contract method, in the correct order and format. + * AuthenticationProviderDetail + * Authentication provider details with type-based discrimination */ - params?: Array; + profiles: Array< + | { + email: string; + emailVerified: boolean; + familyName?: string; + givenName?: string; + hd: string; + id: string; + locale: string; + name?: string; + picture: string; + type: "google"; + } + | { + email?: string; + firstName?: string; + id: string; + lastName?: string; + name?: string; + picture?: string; + type: "facebook"; + } + | { + email?: string; + emailVerified: boolean; + id: string; + isPrivateEmail: boolean; + type: "apple"; + } + | { + avatar?: string; + id: string; + name?: string; + type: "github"; + username: string; + } + | { + avatar: string; + email?: string; + emailVerified: boolean; + id: string; + type: "discord"; + username: string; + } + | { + avatar?: string; + id: string; + name: string; + type: "coinbase"; + } + | { + id: string; + name: string; + type: "x"; + username: string; + profileImageUrl?: string; + } + | { + id: string; + displayName: string; + avatarUrl: string; + unionId?: string; + type: "tiktok"; + } + | { + avatar?: string; + id: string; + metadata: { + avatar: { + large?: string; + medium?: string; + small?: string; + }; + personaname?: string; + profileurl?: string; + realname?: string; + }; + type: "steam"; + username?: string; + } + | { + firstName?: string; + id: string; + lastName?: string; + picture?: string; + type: "telegram"; + username?: string; + } + | { + avatar?: string; + description?: string; + email?: string; + id: string; + type: "twitch"; + username: string; + } + | { + avatar?: string; + id: string; + type: "line"; + username?: string; + } + | { + fid: string; + id: string; + type: "farcaster"; + walletAddress?: string; + } + | { + algorithm: string; + credentialId: string; + publicKey: string; + type: "passkey"; + } + | { + email: string; + id: string; + type: "email"; + } + | { + id: string; + pregeneratedIdentifier: string; + type: "pre_generation"; + } + | { + id: string; + phone: string; + type: "phone"; + } + | { + id: string; + type: "siwe"; + walletAddress: string; + } + | { + id: string; + type: "guest"; + } + | { + id: string; + type: "backend"; + } + | { + identifier: string; + type: "server"; + } + | { + authProviderId?: string; + email?: string; + id: string; + phone?: string; + type: "custom_jwt"; + walletAddress?: string; + } + | { + authProviderId?: string; + email?: string; + id: string; + phone?: string; + type: "custom_auth_endpoint"; + walletAddress?: string; + } + >; /** - * Amount of native token to send with the transaction in wei. Required for payable methods. + * The smart wallet address with EIP-4337 support. This address enables gasless transactions and advanced wallet features. */ - value?: string; - }>; - /** - * The blockchain network identifier. Common values include: 1 (Ethereum), 8453 (Base), 137 (Polygon), 56 (BSC), 43114 (Avalanche), 42161 (Arbitrum), 10 (Optimism). - */ - chainId: number; - /** - * The wallet address that will send the transaction. - */ - from: string; - }; - path?: never; - query?: never; - url: "/v1/contracts/write"; -}; - -export type WriteContractErrors = { - /** - * Invalid request parameters. This occurs when contract parameters are malformed, method signatures are invalid, insufficient balance, or unsupported contract methods. - */ - 400: unknown; - /** - * Authentication required. For backend usage, include `x-secret-key` header. For frontend usage, include `x-client-id` + `Authorization: Bearer ` headers. - */ - 401: unknown; - /** - * Contract not found. The specified contract address does not exist on the given blockchain network or is not accessible. - */ - 404: unknown; - /** - * Internal server error. This may occur due to blockchain connectivity issues, gas estimation failures, contract execution errors, or unexpected server errors. - */ - 500: unknown; -}; - -export type WriteContractResponses = { - /** - * Contract write operations submitted successfully. Returns transaction IDs for tracking and monitoring. - */ - 200: { - result: { + smartWalletAddress?: string; /** - * Array of unique identifiers for the submitted transactions. Use these to track transaction status. + * The wallet's public key in hexadecimal format. Useful for peer-to-peer encryption and cryptographic operations. */ - transactionIds: Array; + publicKey?: string; }; }; }; -export type WriteContractResponse = - WriteContractResponses[keyof WriteContractResponses]; +export type CreateUserWalletResponse = + CreateUserWalletResponses[keyof CreateUserWalletResponses]; -export type ListWalletsData = { +export type ListServerWalletsData = { body?: never; path?: never; query?: { limit?: number; page?: number; - /** - * Type of wallet to fetch, default is user - */ - type?: "user" | "server"; }; - url: "/v1/wallets"; + url: "/v1/wallets/server"; }; -export type ListWalletsErrors = { +export type ListServerWalletsErrors = { /** * Authentication required. The request must include a valid `x-secret-key` header for backend authentication. */ @@ -754,9 +1106,9 @@ export type ListWalletsErrors = { 500: unknown; }; -export type ListWalletsResponses = { +export type ListServerWalletsResponses = { /** - * Returns a list of wallet addresses, smart wallet addresses, and auth details. + * Returns a list of server wallet addresses, smart wallet addresses, and auth details. */ 200: { result: { @@ -771,30 +1123,31 @@ export type ListWalletsResponses = { /** * Number of items per page */ - limit: number; + limit?: number; /** * Current page number */ - page: number; + page?: number; /** * Total number of items available */ totalCount?: number; }; /** - * Array of user or server wallets + * Array of server wallets */ wallets: Array<{ /** - * The EOA (Externally Owned Account) address of the wallet. This is the traditional wallet address. + * The EOA (Externally Owned Wallet) address of the wallet. This is the traditional wallet address. */ - address: string; + address?: string; /** * The date and time the wallet was created */ - createdAt: string; + createdAt?: string; /** - * The profiles linked to the wallet, can be email, phone, google etc, or backend for developer created wallets + * AuthenticationProviderDetail + * Authentication provider details with type-based discrimination */ profiles: Array< | { @@ -851,6 +1204,14 @@ export type ListWalletsResponses = { name: string; type: "x"; username: string; + profileImageUrl?: string; + } + | { + id: string; + displayName: string; + avatarUrl: string; + unionId?: string; + type: "tiktok"; } | { avatar?: string; @@ -952,18 +1313,25 @@ export type ListWalletsResponses = { } >; /** - * The smart wallet address with EIP-4337 support. This address enables gasless transactions and advanced account features. + * The smart wallet address with EIP-4337 support. This address enables gasless transactions and advanced wallet features. */ smartWalletAddress?: string; + /** + * The wallet's public key in hexadecimal format. Useful for peer-to-peer encryption and cryptographic operations. + */ + publicKey?: string; }>; }; }; }; -export type ListWalletsResponse = - ListWalletsResponses[keyof ListWalletsResponses]; +export type ListServerWalletsResponse = + ListServerWalletsResponses[keyof ListServerWalletsResponses]; -export type CreateWalletData = { +export type CreateServerWalletData = { + /** + * Request body for creating a wallet + */ body?: { /** * Unique identifier for wallet creation or retrieval. Can be user ID, email, or any unique string. The same identifier will always return the same wallet. @@ -972,10 +1340,10 @@ export type CreateWalletData = { }; path?: never; query?: never; - url: "/v1/wallets"; + url: "/v1/wallets/server"; }; -export type CreateWalletErrors = { +export type CreateServerWalletErrors = { /** * Invalid request parameters. This occurs when the identifier format is invalid or required parameters are missing. */ @@ -985,27 +1353,28 @@ export type CreateWalletErrors = { */ 401: unknown; /** - * Internal server error. This may occur due to wallet service unavailability, smart account deployment issues, or unexpected server errors. + * Internal server error. This may occur due to wallet service unavailability, smart wallet deployment issues, or unexpected server errors. */ 500: unknown; }; -export type CreateWalletResponses = { +export type CreateServerWalletResponses = { /** - * Wallet created or connected successfully. Returns wallet addresses for subsequent operations. + * Server wallet created or connected successfully. Returns wallet addresses for subsequent operations. */ 200: { result: { /** - * The EOA (Externally Owned Account) address of the wallet. This is the traditional wallet address. + * The EOA (Externally Owned Wallet) address of the wallet. This is the traditional wallet address. */ - address: string; + address?: string; /** * The date and time the wallet was created */ - createdAt: string; + createdAt?: string; /** - * The profiles linked to the wallet, can be email, phone, google etc, or backend for developer created wallets + * AuthenticationProviderDetail + * Authentication provider details with type-based discrimination */ profiles: Array< | { @@ -1062,6 +1431,14 @@ export type CreateWalletResponses = { name: string; type: "x"; username: string; + profileImageUrl?: string; + } + | { + id: string; + displayName: string; + avatarUrl: string; + unionId?: string; + type: "tiktok"; } | { avatar?: string; @@ -1163,36 +1540,344 @@ export type CreateWalletResponses = { } >; /** - * The smart wallet address with EIP-4337 support. This address enables gasless transactions and advanced account features. + * The smart wallet address with EIP-4337 support. This address enables gasless transactions and advanced wallet features. + */ + smartWalletAddress?: string; + /** + * The wallet's public key in hexadecimal format. Useful for peer-to-peer encryption and cryptographic operations. + */ + publicKey?: string; + }; + }; +}; + +export type CreateServerWalletResponse = + CreateServerWalletResponses[keyof CreateServerWalletResponses]; + +export type GetWalletBalanceData = { + body?: never; + path: { + /** + * A valid Ethereum address (0x-prefixed hex string) or ENS name (e.g., vitalik.eth). + */ + address: string; + }; + query: { + /** + * Chain ID(s) to request balance data for. You can specify multiple chain IDs by repeating the parameter, up to a maximum of 50. Example: ?chainId=1&chainId=137 + */ + chainId: Array; + /** + * The token contract address. Omit for native token (ETH, MATIC, etc.). + */ + tokenAddress?: string; + }; + url: "/v1/wallets/{address}/balance"; +}; + +export type GetWalletBalanceErrors = { + /** + * Invalid request parameters. This occurs when the wallet address format is invalid, chainId array is empty or exceeds the maximum limit of 50, or chain IDs are invalid. + */ + 400: unknown; + /** + * Authentication required. The request must include a valid `x-client-id` header for frontend usage or x-secret-key for backend usage. + */ + 401: unknown; + /** + * Internal server error. This may occur due to blockchain connectivity issues, RPC service unavailability, or unexpected server errors. + */ + 500: unknown; +}; + +export type GetWalletBalanceResponses = { + /** + * Wallet native balances retrieved successfully. Returns detailed native token balance information for each chain including token metadata and formatted values. + */ + 200: { + result: Array<{ + /** + * The blockchain network ID + */ + chainId: number; + /** + * Number of decimal places for the token + */ + decimals: number; + /** + * Human-readable balance formatted with appropriate decimal places + */ + displayValue: string; + /** + * The token name (e.g., 'Ether', 'USD Coin') + */ + name: string; + /** + * The token symbol (e.g., 'ETH', 'USDC') + */ + symbol: string; + /** + * The token contract address. Returns zero address (0x0...0) for native tokens. + */ + tokenAddress: string; + /** + * Raw balance value as string in smallest unit (wei for ETH, etc.) + */ + value: string; + }>; + }; +}; + +export type GetWalletBalanceResponse = + GetWalletBalanceResponses[keyof GetWalletBalanceResponses]; + +export type GetWalletTransactionsData = { + body?: never; + path: { + /** + * A valid Ethereum address (0x-prefixed hex string) or ENS name (e.g., vitalik.eth). + */ + address: string; + }; + query: { + /** + * Filter by block timestamp (Unix timestamp) greater than or equal to this value + */ + filterBlockTimestampGte?: number; + /** + * Filter by block timestamp (Unix timestamp) less than or equal to this value + */ + filterBlockTimestampLte?: number; + /** + * Filter by block number greater than or equal to this value + */ + filterBlockNumberGte?: number; + /** + * Filter by block number less than or equal to this value + */ + filterBlockNumberLte?: number; + /** + * Filter by transaction value (in wei) greater than this value + */ + filterValueGt?: string; + /** + * Filter by function selector (4-byte method ID), e.g., '0xa9059cbb' for ERC-20 transfer + */ + filterFunctionSelector?: string; + /** + * Current page number + */ + page?: number; + /** + * Number of items per page + */ + limit?: number; + /** + * Sort order: 'asc' for ascending, 'desc' for descending + */ + sortOrder?: "asc" | "desc"; + /** + * Chain ID(s) to request transaction data for. You can specify multiple chain IDs by repeating the parameter, up to a maximum of 50. Example: ?chainId=1&chainId=137 + */ + chainId: Array; + }; + url: "/v1/wallets/{address}/transactions"; +}; + +export type GetWalletTransactionsErrors = { + /** + * Invalid request parameters. This occurs when the wallet address format is invalid, chainId array is empty or exceeds the maximum limit of 50, or pagination parameters are out of range. + */ + 400: unknown; + /** + * Authentication required. The request must include a valid `x-client-id` header for frontend usage or x-secret-key for backend usage. + */ + 401: unknown; + /** + * Wallet not found or no transactions available for the specified wallet address on the given blockchain networks. + */ + 404: unknown; + /** + * Internal server error. This may occur due to network connectivity issues, external service unavailability, or unexpected server errors. + */ + 500: unknown; +}; + +export type GetWalletTransactionsResponses = { + /** + * Wallet transactions retrieved successfully. Returns transaction data with metadata including pagination information and chain details. Includes decoded function calls when ABI is available. + */ + 200: { + result: { + pagination: { + /** + * Whether there are more items available + */ + hasMore?: boolean; + /** + * Number of items per page + */ + limit?: number; + /** + * Current page number + */ + page?: number; + /** + * Total number of items available + */ + totalCount?: number; + }; + /** + * Array of wallet transactions. */ - smartWalletAddress?: string; + transactions: Array<{ + /** + * The hash of the block containing this transaction. + */ + blockHash: string; + /** + * The block number containing this transaction. + */ + blockNumber: number; + /** + * The timestamp of the block (Unix timestamp). + */ + blockTimestamp: number; + /** + * The chain ID where the transaction occurred. + */ + chainId: string; + /** + * Contract address created if this was a contract creation transaction. + */ + contractAddress?: string; + /** + * Total gas used by all transactions in this block up to and including this one. + */ + cumulativeGasUsed?: number; + /** + * The transaction input data. + */ + data: string; + /** + * Decoded transaction data (included when ABI is available). + */ + decoded?: { + /** + * Object containing decoded function parameters. + */ + inputs: { + [key: string]: unknown; + }; + /** + * The function name. + */ + name: string; + /** + * The function signature. + */ + signature: string; + }; + /** + * The effective gas price paid (in wei as string). + */ + effectiveGasPrice?: string; + /** + * The address that initiated the transaction. + */ + fromAddress: string; + /** + * The function selector (first 4 bytes of the transaction data). + */ + functionSelector: string; + /** + * The gas limit for the transaction. + */ + gas: number; + /** + * The gas price used for the transaction (in wei as string). + */ + gasPrice: string; + /** + * The amount of gas used by the transaction. + */ + gasUsed?: number; + /** + * The transaction hash. + */ + hash: string; + /** + * Maximum fee per gas (EIP-1559). + */ + maxFeePerGas?: string; + /** + * Maximum priority fee per gas (EIP-1559). + */ + maxPriorityFeePerGas?: string; + /** + * The transaction nonce. + */ + nonce: number; + /** + * The transaction status (1 for success, 0 for failure). + */ + status: number; + /** + * The address that received the transaction. + */ + toAddress: string; + /** + * The index of the transaction within the block. + */ + transactionIndex: number; + /** + * The transaction type (0=legacy, 1=EIP-2930, 2=EIP-1559). + */ + transactionType?: number; + /** + * The value transferred in the transaction (in wei as string). + */ + value: string; + }>; }; }; }; -export type CreateWalletResponse = - CreateWalletResponses[keyof CreateWalletResponses]; +export type GetWalletTransactionsResponse = + GetWalletTransactionsResponses[keyof GetWalletTransactionsResponses]; -export type GetWalletBalanceData = { +export type GetWalletTokensData = { body?: never; path: { /** - * A valid Ethereum address, which is a 40-character hexadecimal string (0x prefixed) representing an account on the Ethereum blockchain. + * A valid Ethereum address (0x-prefixed hex string) or ENS name (e.g., vitalik.eth). */ address: string; }; query: { /** - * Chain ID(s) to request balance data for. You can specify multiple chain IDs by repeating the parameter, up to a maximum of 50. Example: ?chainId=1&chainId=137 + * Chain ID(s) to request token data for. You can specify multiple chain IDs by repeating the parameter, up to a maximum of 50. Example: ?chainId=1&chainId=137 */ chainId: Array; + /** + * Token addresses to filter by. If provided, only tokens with these addresses will be returned. + */ + tokenAddresses?: Array; + /** + * The number of tokens to return per chain (default: 20, max: 500). + */ + limit?: number; + /** + * The page number for pagination (default: 1, max: 20). + */ + page?: number; }; - url: "/v1/wallets/{address}/balance"; + url: "/v1/wallets/{address}/tokens"; }; -export type GetWalletBalanceErrors = { +export type GetWalletTokensErrors = { /** - * Invalid request parameters. This occurs when the wallet address format is invalid, chainId array is empty or exceeds the maximum limit of 50, or chain IDs are invalid. + * Invalid request parameters. This occurs when the wallet address format is invalid, chainId array is empty or exceeds the maximum limit of 50, or pagination parameters are out of range. */ 400: unknown; /** @@ -1200,90 +1885,148 @@ export type GetWalletBalanceErrors = { */ 401: unknown; /** - * Internal server error. This may occur due to blockchain connectivity issues, RPC service unavailability, or unexpected server errors. + * Wallet not found or no tokens available for the specified wallet address on the given blockchain networks. + */ + 404: unknown; + /** + * Internal server error. This may occur due to network connectivity issues, external service unavailability, or unexpected server errors. */ 500: unknown; }; -export type GetWalletBalanceResponses = { +export type GetWalletTokensResponses = { /** - * Wallet native balances retrieved successfully. Returns detailed native token balance information for each chain including token metadata and formatted values. + * Wallet tokens retrieved successfully. Returns token data with metadata including pagination information and chain details. Includes token balances, metadata, and price information when available. */ 200: { - result: Array<{ - /** - * The blockchain network ID - */ - chainId: number; - /** - * Number of decimal places for the token - */ - decimals: number; - /** - * Human-readable balance formatted with appropriate decimal places - */ - displayValue: string; - /** - * The token name (e.g., 'Ether', 'USD Coin') - */ - name: string; - /** - * The token symbol (e.g., 'ETH', 'USDC') - */ - symbol: string; - /** - * The token contract address. Returns zero address (0x0...0) for native tokens. - */ - tokenAddress: string; + result: { + pagination: { + /** + * Whether there are more items available + */ + hasMore?: boolean; + /** + * Number of items per page + */ + limit?: number; + /** + * Current page number + */ + page?: number; + /** + * Total number of items available + */ + totalCount?: number; + }; /** - * Raw balance value as string in smallest unit (wei for ETH, etc.) + * Array of wallet tokens. */ - value: string; - }>; + tokens: Array<{ + /** + * The token balance as a string + */ + balance: string; + /** + * The chain ID of the token + */ + chain_id: number; + /** + * The number of decimal places + */ + decimals?: number; + /** + * The token name + */ + name?: string; + /** + * The token icon URI + */ + icon_uri?: string; + /** + * Price data + */ + prices?: { + [key: string]: number; + }; + /** + * Price data for the token + */ + price_data?: { + /** + * The circulating supply of the token + */ + circulating_supply?: number; + /** + * The market cap of the token in USD + */ + market_cap_usd?: number; + /** + * The percentage change of the token in the last 24 hours + */ + percent_change_24h?: number; + /** + * The timestamp of the latest price update + */ + price_timestamp?: string; + /** + * The price of the token in USD + */ + price_usd?: number; + /** + * The total supply of the token + */ + total_supply?: number; + /** + * The volume of the token in USD + */ + volume_24h_usd?: number; + }; + /** + * The token symbol + */ + symbol?: string; + /** + * The contract address of the token + */ + token_address: string; + }>; + }; }; }; -export type GetWalletBalanceResponse = - GetWalletBalanceResponses[keyof GetWalletBalanceResponses]; +export type GetWalletTokensResponse = + GetWalletTokensResponses[keyof GetWalletTokensResponses]; -export type GetWalletTransactionsData = { +export type GetWalletNftsData = { body?: never; path: { /** - * A valid Ethereum address, which is a 40-character hexadecimal string (0x prefixed) representing an account on the Ethereum blockchain. + * A valid Ethereum address (0x-prefixed hex string) or ENS name (e.g., vitalik.eth). */ address: string; }; query: { /** - * Chain ID(s) to request transaction data for. You can specify multiple chain IDs by repeating the parameter, up to a maximum of 50. Example: ?chainId=1&chainId=137 + * Chain ID(s) to request NFT data for. You can specify multiple chain IDs by repeating the parameter, up to a maximum of 50. Example: ?chainId=1&chainId=137 */ chainId: Array; /** - * Whether to enable ABI decoding of transaction data. When true, returns decoded function calls if ABI is available. + * NFT contract addresses to filter by. If provided, only NFTs with these addresses will be returned. */ - decode?: boolean; + contractAddresses?: Array; /** - * The number of transactions to return per chain (default: 20, max: 500). + * The number of NFTs to return per chain (default: 20, max: 500). */ limit?: number; /** - * The page number for pagination (default: 0, max: 20). + * The page number for pagination (default: 1, max: 20). */ page?: number; - /** - * Sort order - ascending or descending (default: desc). - */ - sortOrder?: "asc" | "desc"; - /** - * Start time for filtering transactions (Unix timestamp). Default is 3 months ago. - */ - startTime?: number; }; - url: "/v1/wallets/{address}/transactions"; + url: "/v1/wallets/{address}/nfts"; }; -export type GetWalletTransactionsErrors = { +export type GetWalletNftsErrors = { /** * Invalid request parameters. This occurs when the wallet address format is invalid, chainId array is empty or exceeds the maximum limit of 50, or pagination parameters are out of range. */ @@ -1293,7 +2036,7 @@ export type GetWalletTransactionsErrors = { */ 401: unknown; /** - * Wallet not found or no transactions available for the specified wallet address on the given blockchain networks. + * Wallet not found or no NFTs available for the specified wallet address on the given blockchain networks. */ 404: unknown; /** @@ -1302,416 +2045,422 @@ export type GetWalletTransactionsErrors = { 500: unknown; }; -export type GetWalletTransactionsResponses = { +export type GetWalletNftsResponses = { /** - * Wallet transactions retrieved successfully. Returns transaction data with metadata including pagination information and chain details. When decode=true, includes decoded function calls if ABI is available. + * Wallet NFTs retrieved successfully. Returns NFT data with metadata including pagination information and chain details. Includes NFT metadata, attributes, and collection information when available. */ 200: { result: { - pagination: { - /** - * Whether there are more items available - */ - hasMore?: boolean; - /** - * Number of items per page - */ - limit: number; - /** - * Current page number - */ - page: number; - /** - * Total number of items available - */ - totalCount?: number; - }; /** - * Array of wallet transactions. + * Array of wallet NFTs. */ - transactions: Array<{ - /** - * The hash of the block containing this transaction. - */ - blockHash: string; - /** - * The block number containing this transaction. - */ - blockNumber: number; - /** - * The timestamp of the block (Unix timestamp). - */ - blockTimestamp: number; - /** - * The chain ID where the transaction occurred. - */ - chainId: string; + nfts: Array<{ /** - * Contract address created if this was a contract creation transaction. + * The animation URL of the NFT */ - contractAddress?: string; + animation_url?: string; /** - * Total gas used by all transactions in this block up to and including this one. + * The attributes/traits of the NFT */ - cumulativeGasUsed?: number; + attributes?: Array<{ + /** + * The display type + */ + display_type?: string; + /** + * The trait type + */ + trait_type?: string; + /** + * The trait value + */ + value?: string | number; + }>; /** - * The transaction input data. + * The chain ID of the NFT */ - data: string; + chain_id: number; /** - * Decoded transaction data (only present when decode=true and ABI is available). + * Collection information */ - decoded?: { + collection?: { /** - * Object containing decoded function parameters. + * The collection description */ - inputs: { - [key: string]: unknown; - }; + description?: string; /** - * The function name. + * The collection external URL */ - name: string; + external_url?: string; /** - * The function signature. + * The collection image URL */ - signature: string; + image?: string; + /** + * The collection name + */ + name?: string; }; /** - * The effective gas price paid (in wei as string). - */ - effectiveGasPrice?: string; - /** - * The address that initiated the transaction. - */ - fromAddress: string; - /** - * The function selector (first 4 bytes of the transaction data). + * The description of the NFT */ - functionSelector: string; + description?: string; /** - * The gas limit for the transaction. + * The external URL of the NFT */ - gas: number; + external_url?: string; /** - * The gas price used for the transaction (in wei as string). + * The image URL of the NFT */ - gasPrice: string; + image_url?: string; /** - * The amount of gas used by the transaction. + * Additional metadata for the NFT */ - gasUsed?: number; + metadata?: { + [key: string]: unknown; + }; /** - * The transaction hash. + * The name of the NFT */ - hash: string; + name?: string; /** - * Maximum fee per gas (EIP-1559). + * The contract address of the NFT collection */ - maxFeePerGas?: string; + token_address: string; /** - * Maximum priority fee per gas (EIP-1559). + * The token ID of the NFT */ - maxPriorityFeePerGas?: string; + token_id: string; + }>; + pagination: { /** - * The transaction nonce. + * Whether there are more items available */ - nonce: number; + hasMore?: boolean; /** - * The transaction status (1 for success, 0 for failure). + * Number of items per page */ - status: number; + limit?: number; /** - * The address that received the transaction. + * Current page number */ - toAddress: string; + page?: number; /** - * The index of the transaction within the block. + * Total number of items available */ - transactionIndex: number; + totalCount?: number; + }; + }; + }; +}; + +export type GetWalletNftsResponse = + GetWalletNftsResponses[keyof GetWalletNftsResponses]; + +export type SignMessageData = { + /** + * Request body for signing a message + */ + body?: { + /** + * The wallet address or ENS name that will sign the message. + */ + from: string; + /** + * The blockchain network identifier where the signing will occur. Common values include: 1 (Ethereum), 137 (Polygon), 56 (BSC). + */ + chainId: number; + /** + * The message to be signed. Can be plain text or hexadecimal format (starting with 0x). The format is automatically detected. + */ + message: string; + }; + path?: never; + query?: never; + url: "/v1/wallets/sign-message"; +}; + +export type SignMessageErrors = { + /** + * Invalid request parameters. This occurs when the wallet address format is invalid, chainId is not supported, or the message format is incorrect. + */ + 400: unknown; + /** + * Authentication required. For backend usage, include `x-secret-key` header. For frontend usage, include `x-client-id` + `Authorization: Bearer ` headers. + */ + 401: unknown; + /** + * Internal server error. This may occur due to wallet connectivity issues, signing service unavailability, or unexpected server errors. + */ + 500: unknown; +}; + +export type SignMessageResponses = { + /** + * Message signed successfully. Returns the cryptographic signature that can be used for verification. + */ + 200: { + result: { + /** + * The cryptographic signature in hexadecimal format. This can be used for verification and authentication purposes. + */ + signature: string; + }; + }; +}; + +export type SignMessageResponse = + SignMessageResponses[keyof SignMessageResponses]; + +export type SignTypedDataData = { + /** + * Request body for signing typed data + */ + body?: { + /** + * The wallet address or ENS name that will sign the typed data. + */ + from: string; + /** + * The blockchain network identifier for EIP-712 domain separation. + */ + chainId: number; + /** + * EIP-712 domain separator containing contract and chain information for signature verification. + */ + domain: { + /** + * Chain ID as string for domain separation + */ + chainId?: string; + /** + * The domain name (e.g., token name) + */ + name?: string; + /** + * Optional salt for additional entropy + */ + salt?: string; + /** + * The contract address that will verify this signature + */ + verifyingContract?: string; + /** + * Domain version for signature compatibility + */ + version?: string; + }; + /** + * The structured data to be signed, matching the defined types schema. + */ + message: { + [key: string]: unknown; + }; + /** + * The primary type name from the types object that defines the main structure being signed. + */ + primaryType: string; + /** + * Type definitions for the structured data, following EIP-712 specifications. + */ + types: { + [key: string]: Array<{ /** - * The transaction type (0=legacy, 1=EIP-2930, 2=EIP-1559). + * The field name */ - transactionType?: number; + name: string; /** - * The value transferred in the transaction (in wei as string). + * The Solidity type (e.g., 'address', 'uint256') */ - value: string; + type: string; }>; }; }; + path?: never; + query?: never; + url: "/v1/wallets/sign-typed-data"; }; -export type GetWalletTransactionsResponse = - GetWalletTransactionsResponses[keyof GetWalletTransactionsResponses]; +export type SignTypedDataErrors = { + /** + * Invalid request parameters. This occurs when the typed data structure is malformed, domain parameters are incorrect, or wallet address format is invalid. + */ + 400: unknown; + /** + * Authentication required. The request must include valid `x-wallet-access-token` headers for accessing the wallet, as well as a x-client-id (frontend) or x-secret-key (backend) for project authentication. + */ + 401: unknown; + /** + * Internal server error. This may occur due to wallet connectivity issues, signing service unavailability, or unexpected server errors. + */ + 500: unknown; +}; -export type GetWalletTokensData = { - body?: never; - path: { +export type SignTypedDataResponses = { + /** + * Typed data signed successfully. Returns the EIP-712 compliant signature that can be used for on-chain verification. + */ + 200: { + result: { + /** + * The cryptographic signature in hexadecimal format. This can be used for verification and authentication purposes. + */ + signature: string; + }; + }; +}; + +export type SignTypedDataResponse = + SignTypedDataResponses[keyof SignTypedDataResponses]; + +export type SendTokensData = { + /** + * Request body for sending tokens to multiple recipients. Supports native tokens, ERC20, ERC721, and ERC1155 transfers based on the provided parameters. + */ + body?: { /** - * A valid Ethereum address, which is a 40-character hexadecimal string (0x prefixed) representing an account on the Ethereum blockchain. + * The wallet address or ENS name that will send the tokens. */ - address: string; - }; - query: { + from: string; /** - * Chain ID(s) to request token data for. You can specify multiple chain IDs by repeating the parameter, up to a maximum of 50. Example: ?chainId=1&chainId=137 + * The blockchain network identifier where the transfer will be executed. */ - chainId: Array; + chainId: number; /** - * The number of tokens to return per chain (default: 20, max: 500). + * Array of recipients and quantities. Maximum 100 recipients per request. */ - limit?: number; + recipients: Array<{ + /** + * The recipient wallet address or ENS name + */ + address: string; + /** + * The amount to send. For native tokens and ERC20: amount in wei/smallest unit. For ERC721: should be '1'. For ERC1155: the number of tokens to transfer. + */ + quantity: string; + }>; /** - * The page number for pagination (default: 0, max: 20). + * The token contract address. Omit for native token (ETH, MATIC, etc.) transfers. */ - page?: number; + tokenAddress?: string; + /** + * The token ID for NFT transfers (ERC721/ERC1155). Required for NFT transfers. + */ + tokenId?: string; }; - url: "/v1/wallets/{address}/tokens"; + path?: never; + query?: never; + url: "/v1/wallets/send"; }; -export type GetWalletTokensErrors = { +export type SendTokensErrors = { /** - * Invalid request parameters. This occurs when the wallet address format is invalid, chainId array is empty or exceeds the maximum limit of 50, or pagination parameters are out of range. + * Invalid request parameters. This occurs when token parameters are malformed, insufficient balance, invalid contract data, or unsupported token type. */ 400: unknown; /** - * Authentication required. The request must include a valid `x-client-id` header for frontend usage or x-secret-key for backend usage. + * Authentication required. For backend usage, include `x-secret-key` header. For frontend usage, include `x-client-id` + `Authorization: Bearer ` headers. */ 401: unknown; /** - * Wallet not found or no tokens available for the specified wallet address on the given blockchain networks. - */ - 404: unknown; - /** - * Internal server error. This may occur due to network connectivity issues, external service unavailability, or unexpected server errors. + * Internal server error. This may occur due to blockchain connectivity issues, gas estimation failures, contract execution errors, or unexpected server errors. */ 500: unknown; }; -export type GetWalletTokensResponses = { +export type SendTokensResponses = { /** - * Wallet tokens retrieved successfully. Returns token data with metadata including pagination information and chain details. Includes token balances, metadata, and price information when available. + * Tokens sent successfully. Returns transaction IDs for tracking and monitoring. */ 200: { result: { - pagination: { - /** - * Whether there are more items available - */ - hasMore?: boolean; - /** - * Number of items per page - */ - limit: number; - /** - * Current page number - */ - page: number; - /** - * Total number of items available - */ - totalCount?: number; - }; /** - * Array of wallet tokens. + * Array of transaction IDs for the submitted transfers. One ID per recipient. */ - tokens: Array<{ - /** - * The token balance as a string - */ - balance: string; - /** - * The chain ID of the token - */ - chain_id: number; - /** - * The number of decimal places - */ - decimals?: number; - /** - * The token name - */ - name?: string; - /** - * Price data for the token - */ - price_data?: { - /** - * The circulating supply of the token - */ - circulating_supply?: number; - /** - * The market cap of the token in USD - */ - market_cap_usd?: number; - /** - * The percentage change of the token in the last 24 hours - */ - percent_change_24h?: number; - /** - * The timestamp of the latest price update - */ - price_timestamp?: string; - /** - * The price of the token in USD - */ - price_usd?: number; - /** - * The total supply of the token - */ - total_supply?: number; - /** - * The volume of the token in USD - */ - volume_24h_usd?: number; - }; - /** - * The token symbol - */ - symbol?: string; - /** - * The contract address of the token - */ - token_address: string; - }>; + transactionIds: Array; }; }; }; -export type GetWalletTokensResponse = - GetWalletTokensResponses[keyof GetWalletTokensResponses]; +export type SendTokensResponse = SendTokensResponses[keyof SendTokensResponses]; -export type GetWalletNftsData = { +export type ListContractsData = { body?: never; - path: { - /** - * A valid Ethereum address, which is a 40-character hexadecimal string (0x prefixed) representing an account on the Ethereum blockchain. - */ - address: string; - }; - query: { - /** - * Chain ID(s) to request NFT data for. You can specify multiple chain IDs by repeating the parameter, up to a maximum of 50. Example: ?chainId=1&chainId=137 - */ - chainId: Array; + path?: never; + query?: { /** - * The number of NFTs to return per chain (default: 20, max: 500). + * The number of contracts to return (default: 20, max: 100). */ limit?: number; /** - * The page number for pagination (default: 0, max: 20). + * The page number for pagination (default: 1). */ page?: number; }; - url: "/v1/wallets/{address}/nfts"; + url: "/v1/contracts"; }; -export type GetWalletNftsErrors = { +export type ListContractsErrors = { /** - * Invalid request parameters. This occurs when the wallet address format is invalid, chainId array is empty or exceeds the maximum limit of 50, or pagination parameters are out of range. + * Invalid request parameters */ 400: unknown; /** - * Authentication required. The request must include a valid `x-client-id` header for frontend usage or x-secret-key for backend usage. + * Authentication required. The request must include a valid `x-secret-key` header for backend authentication. */ 401: unknown; /** - * Wallet not found or no NFTs available for the specified wallet address on the given blockchain networks. + * Rate limit exceeded */ - 404: unknown; + 429: unknown; /** - * Internal server error. This may occur due to network connectivity issues, external service unavailability, or unexpected server errors. + * Internal server error */ 500: unknown; }; -export type GetWalletNftsResponses = { - /** - * Wallet NFTs retrieved successfully. Returns NFT data with metadata including pagination information and chain details. Includes NFT metadata, attributes, and collection information when available. - */ - 200: { - result: { - /** - * Array of wallet NFTs. - */ - nfts: Array<{ - /** - * The animation URL of the NFT - */ - animation_url?: string; - /** - * The attributes/traits of the NFT - */ - attributes?: Array<{ - /** - * The display type - */ - display_type?: string; - /** - * The trait type - */ - trait_type?: string; - /** - * The trait value - */ - value?: string | number; - }>; - /** - * The chain ID of the NFT - */ - chain_id: number; +export type ListContractsResponses = { + /** + * Successfully retrieved list of contracts + */ + 200: { + result: { + /** + * Array of contracts imported by the client. + */ + contracts: Array<{ /** - * Collection information + * The contract address. */ - collection?: { - /** - * The collection description - */ - description?: string; - /** - * The collection external URL - */ - external_url?: string; - /** - * The collection image URL - */ - image?: string; - /** - * The collection name - */ - name?: string; - }; + address: string; /** - * The description of the NFT + * The chain ID where the contract is deployed. */ - description?: string; + chainId: string; /** - * The external URL of the NFT + * The date when the contract was deployed. */ - external_url?: string; + deployedAt?: string; /** - * The image URL of the NFT + * The contract ID. */ - image_url?: string; + id?: string; /** - * Additional metadata for the NFT + * The date when the contract was imported to the dashboard. */ - metadata?: { - [key: string]: unknown; - }; + importedAt: string; /** - * The name of the NFT + * The contract name, if available. */ name?: string; /** - * The contract address of the NFT collection + * The contract symbol, if available. */ - token_address: string; + symbol?: string; /** - * The token ID of the NFT + * The contract type (e.g., ERC20, ERC721, etc.). */ - token_id: string; + type?: string; }>; pagination: { /** @@ -1721,11 +2470,11 @@ export type GetWalletNftsResponses = { /** * Number of items per page */ - limit: number; + limit?: number; /** * Current page number */ - page: number; + page?: number; /** * Total number of items available */ @@ -1735,679 +2484,946 @@ export type GetWalletNftsResponses = { }; }; -export type GetWalletNftsResponse = - GetWalletNftsResponses[keyof GetWalletNftsResponses]; +export type ListContractsResponse = + ListContractsResponses[keyof ListContractsResponses]; + +export type DeployContractData = { + /** + * Contract deployment specification for raw bytecode deployment. + */ + body?: { + /** + * The blockchain network identifier. Common values include: 1 (Ethereum), 8453 (Base), 137 (Polygon), 56 (BSC), 43114 (Avalanche), 42161 (Arbitrum), 10 (Optimism). + */ + chainId: number; + /** + * The wallet address or ENS name that will deploy the contract. + */ + from: string; + /** + * The contract bytecode as a hex string. + */ + bytecode: string; + /** + * The contract ABI array. + */ + abi: Array; + /** + * Object containing constructor parameters for the contract deployment (e.g., { param1: 'value1', param2: 123 }). + */ + constructorParams?: { + [key: string]: unknown; + }; + /** + * Optional salt value for deterministic contract deployment. + */ + salt?: string; + }; + path?: never; + query?: never; + url: "/v1/contracts"; +}; + +export type DeployContractErrors = { + /** + * Invalid request parameters + */ + 400: unknown; + /** + * Authentication required. The request must include a valid `x-secret-key` header for backend authentication. + */ + 401: unknown; + /** + * Rate limit exceeded + */ + 429: unknown; + /** + * Internal server error + */ + 500: unknown; +}; + +export type DeployContractResponses = { + /** + * Contract deployed successfully + */ + 200: { + result: { + /** + * The deployed contract address. + */ + address: string; + /** + * The chain ID where the contract was deployed. + */ + chainId: number; + /** + * The unique identifier for the transaction that deployed the contract. Will not be returned if the contract was already deployed at the predicted address. + */ + transactionId?: string; + }; + }; +}; + +export type DeployContractResponse = + DeployContractResponses[keyof DeployContractResponses]; + +export type ReadContractData = { + body?: { + /** + * Array of contract method calls to execute. Each call specifies a contract address, method signature, and optional parameters. + */ + calls: Array<{ + /** + * The smart contract address or ENS name. + */ + contractAddress: string; + /** + * The contract function signature to call (e.g., 'function approve(address spender, uint256 amount)' or `function balanceOf(address)`). Must start with 'function' followed by the function name and parameters as defined in the contract ABI. + */ + method: string; + /** + * Array of parameters to pass to the contract method, in the correct order and format. + */ + params?: Array; + /** + * Amount of native token to send with the transaction in wei. Required for payable methods. + */ + value?: string; + }>; + /** + * The blockchain network identifier. Common values include: 1 (Ethereum), 8453 (Base), 137 (Polygon), 56 (BSC), 43114 (Avalanche), 42161 (Arbitrum), 10 (Optimism). + */ + chainId: number; + }; + path?: never; + query?: never; + url: "/v1/contracts/read"; +}; + +export type ReadContractErrors = { + /** + * Invalid request parameters. This occurs when the chainId is not supported, contract addresses are invalid, function signatures are malformed, or the calls array is empty. + */ + 400: unknown; + /** + * Authentication required. The request must include a valid `x-client-id` header for frontend usage or x-secret-key for backend usage. + */ + 401: unknown; + /** + * Internal server error. This may occur due to engine connectivity issues, RPC node unavailability, or unexpected server errors. + */ + 500: unknown; +}; + +export type ReadContractResponses = { + /** + * Contract read operations completed successfully. Returns an array of results corresponding to each input call, including both successful and failed operations. + */ + 200: { + /** + * Array of results corresponding to each contract read call. Results are returned in the same order as the input calls. + */ + result: Array<{ + /** + * The result of the contract read operation. The type and format depend on the method's return value as defined in the contract ABI. + */ + data?: unknown; + /** + * Error message if the contract read operation failed. + */ + error?: string; + /** + * Indicates whether the contract read operation was successful. + */ + success: boolean; + }>; + }; +}; + +export type ReadContractResponse = + ReadContractResponses[keyof ReadContractResponses]; + +export type WriteContractData = { + body?: { + /** + * Array of contract method calls to execute. Each call specifies a contract address, method signature, and optional parameters. + */ + calls: Array<{ + /** + * The smart contract address or ENS name. + */ + contractAddress: string; + /** + * The contract function signature to call (e.g., 'function approve(address spender, uint256 amount)' or `function balanceOf(address)`). Must start with 'function' followed by the function name and parameters as defined in the contract ABI. + */ + method: string; + /** + * Array of parameters to pass to the contract method, in the correct order and format. + */ + params?: Array; + /** + * Amount of native token to send with the transaction in wei. Required for payable methods. + */ + value?: string; + }>; + /** + * The blockchain network identifier. Common values include: 1 (Ethereum), 8453 (Base), 137 (Polygon), 56 (BSC), 43114 (Avalanche), 42161 (Arbitrum), 10 (Optimism). + */ + chainId: number; + /** + * The wallet address or ENS name that will send the transaction. + */ + from: string; + }; + path?: never; + query?: never; + url: "/v1/contracts/write"; +}; + +export type WriteContractErrors = { + /** + * Invalid request parameters. This occurs when contract parameters are malformed, method signatures are invalid, insufficient balance, or unsupported contract methods. + */ + 400: unknown; + /** + * Authentication required. For backend usage, include `x-secret-key` header. For frontend usage, include `x-client-id` + `Authorization: Bearer ` headers. + */ + 401: unknown; + /** + * Contract not found. The specified contract address does not exist on the given blockchain network or is not accessible. + */ + 404: unknown; + /** + * Internal server error. This may occur due to blockchain connectivity issues, gas estimation failures, contract execution errors, or unexpected server errors. + */ + 500: unknown; +}; + +export type WriteContractResponses = { + /** + * Contract write operations submitted successfully. Returns transaction IDs for tracking and monitoring. + */ + 200: { + result: { + /** + * Array of unique identifiers for the submitted transactions. Use these to track transaction status. + */ + transactionIds: Array; + }; + }; +}; + +export type WriteContractResponse = + WriteContractResponses[keyof WriteContractResponses]; -export type GetWalletDetailsData = { +export type GetContractTransactionsData = { body?: never; path: { /** - * A valid Ethereum address, which is a 40-character hexadecimal string (0x prefixed) representing an account on the Ethereum blockchain. + * The blockchain network identifier where the contract is deployed. + */ + chainId: number; + /** + * The smart contract address or ENS name. */ address: string; }; - query?: never; - url: "/v1/wallets/{address}"; + query?: { + /** + * Filter by transaction sender address + */ + filterFromAddress?: string; + /** + * Filter by transaction recipient address + */ + filterToAddress?: string; + /** + * Filter by block timestamp (Unix timestamp) greater than or equal to this value + */ + filterBlockTimestampGte?: number; + /** + * Filter by block timestamp (Unix timestamp) less than or equal to this value + */ + filterBlockTimestampLte?: number; + /** + * Filter by block number greater than or equal to this value + */ + filterBlockNumberGte?: number; + /** + * Filter by block number less than or equal to this value + */ + filterBlockNumberLte?: number; + /** + * Filter by transaction value (in wei) greater than this value + */ + filterValueGt?: string; + /** + * Filter by function selector (4-byte method ID), e.g., '0xa9059cbb' for ERC-20 transfer + */ + filterFunctionSelector?: string; + /** + * Current page number + */ + page?: number; + /** + * Number of items per page + */ + limit?: number; + /** + * Sort order: 'asc' for ascending, 'desc' for descending + */ + sortOrder?: "asc" | "desc"; + }; + url: "/v1/contracts/{chainId}/{address}/transactions"; }; -export type GetWalletDetailsErrors = { +export type GetContractTransactionsErrors = { /** - * Invalid request parameters. This occurs when the wallet address format is invalid or malformed. + * Invalid request parameters. This occurs when the contract address or chainId format is invalid, or pagination parameters are out of range. */ 400: unknown; /** - * Authentication required. The request must include a valid `x-secret-key` header for backend authentication. + * Authentication required. The request must include a valid `x-client-id` header for frontend usage or x-secret-key for backend usage. */ 401: unknown; /** - * Wallet not found. The specified wallet address does not exist or is not associated with any user in the system. + * Contract not found or no transactions available for the specified contract address on the given blockchain network. */ 404: unknown; /** - * Internal server error. This may occur due to service unavailability, network connectivity issues, or unexpected server errors. + * Internal server error. This may occur due to network connectivity issues, external service unavailability, or unexpected server errors. */ 500: unknown; }; -export type GetWalletDetailsResponses = { +export type GetContractTransactionsResponses = { /** - * Wallet details retrieved successfully. Returns comprehensive user information including authentication details and linked accounts. + * Contract transactions retrieved successfully. Returns transaction data with metadata including pagination information. Includes decoded function calls when ABI is available. */ 200: { result: { /** - * The EOA (Externally Owned Account) address of the wallet. This is the traditional wallet address. - */ - address: string; - /** - * The date and time the wallet was created - */ - createdAt: string; - /** - * The profiles linked to the wallet, can be email, phone, google etc, or backend for developer created wallets - */ - profiles: Array< - | { - email: string; - emailVerified: boolean; - familyName?: string; - givenName?: string; - hd: string; - id: string; - locale: string; - name?: string; - picture: string; - type: "google"; - } - | { - email?: string; - firstName?: string; - id: string; - lastName?: string; - name?: string; - picture?: string; - type: "facebook"; - } - | { - email?: string; - emailVerified: boolean; - id: string; - isPrivateEmail: boolean; - type: "apple"; - } - | { - avatar?: string; - id: string; - name?: string; - type: "github"; - username: string; - } - | { - avatar: string; - email?: string; - emailVerified: boolean; - id: string; - type: "discord"; - username: string; - } - | { - avatar?: string; - id: string; - name: string; - type: "coinbase"; - } - | { - id: string; - name: string; - type: "x"; - username: string; - } - | { - avatar?: string; - id: string; - metadata: { - avatar: { - large?: string; - medium?: string; - small?: string; - }; - personaname?: string; - profileurl?: string; - realname?: string; - }; - type: "steam"; - username?: string; - } - | { - firstName?: string; - id: string; - lastName?: string; - picture?: string; - type: "telegram"; - username?: string; - } - | { - avatar?: string; - description?: string; - email?: string; - id: string; - type: "twitch"; - username: string; - } - | { - avatar?: string; - id: string; - type: "line"; - username?: string; - } - | { - fid: string; - id: string; - type: "farcaster"; - walletAddress?: string; - } - | { - algorithm: string; - credentialId: string; - publicKey: string; - type: "passkey"; - } - | { - email: string; - id: string; - type: "email"; - } - | { - id: string; - pregeneratedIdentifier: string; - type: "pre_generation"; - } - | { - id: string; - phone: string; - type: "phone"; - } - | { - id: string; - type: "siwe"; - walletAddress: string; - } - | { - id: string; - type: "guest"; - } - | { - id: string; - type: "backend"; - } - | { - identifier: string; - type: "server"; - } - | { - authProviderId?: string; - email?: string; - id: string; - phone?: string; - type: "custom_jwt"; - walletAddress?: string; - } - | { - authProviderId?: string; - email?: string; - id: string; - phone?: string; - type: "custom_auth_endpoint"; - walletAddress?: string; - } - >; - /** - * The smart wallet address with EIP-4337 support. This address enables gasless transactions and advanced account features. + * Array of contract transactions. */ - smartWalletAddress?: string; - }; - }; -}; - -export type GetWalletDetailsResponse = - GetWalletDetailsResponses[keyof GetWalletDetailsResponses]; - -export type SendCodeData = { - /** - * Request body for sending an OTP code to either email or phone - */ - body?: - | { + data: Array<{ + /** + * The hash of the block containing this transaction. + */ + blockHash: string; + /** + * The block number containing this transaction. + */ + blockNumber: number; + /** + * The timestamp of the block (Unix timestamp). + */ + blockTimestamp: number; + /** + * The chain ID where the transaction occurred. + */ + chainId: string; /** - * The email address to send the OTP code to + * Contract address created if this was a contract creation transaction. */ - email: string; + contractAddress?: string; /** - * Send code to email address + * Total gas used by all transactions in this block up to and including this one. */ - type: "email"; - } - | { + cumulativeGasUsed?: number; /** - * The phone number to send the OTP code to + * The transaction input data. */ - phone: string; + data: string; /** - * Send code to phone number + * Decoded transaction data (included when ABI is available). */ - type: "phone"; - }; - path?: never; - query?: never; - url: "/v1/wallets/login/code"; -}; - -export type SendCodeErrors = { - /** - * Invalid request parameters - */ - 400: unknown; - /** - * Internal server error - */ - 500: unknown; -}; - -export type SendCodeResponses = { - /** - * OTP sent successfully - */ - 200: { - success: boolean; - }; -}; - -export type SendCodeResponse = SendCodeResponses[keyof SendCodeResponses]; - -export type VerifyCodeData = { - /** - * Request body for verifying an OTP code for either email or phone - */ - body?: - | { + decoded?: { + /** + * Object containing decoded function parameters. + */ + inputs: { + [key: string]: unknown; + }; + /** + * The function name. + */ + name: string; + /** + * The function signature. + */ + signature: string; + }; /** - * The 6-digit OTP code sent to the email address + * The effective gas price paid (in wei as string). */ - code: string; + effectiveGasPrice?: string; /** - * The email address to verify + * The address that initiated the transaction. */ - email: string; + fromAddress: string; /** - * Verify code for email address + * The function selector (first 4 bytes of the transaction data). */ - type: "email"; - } - | { + functionSelector: string; /** - * The 6-digit OTP code sent to the phone number + * The gas limit for the transaction. */ - code: string; + gas: number; /** - * The phone number to verify + * The gas price used for the transaction (in wei as string). */ - phone: string; + gasPrice: string; /** - * Verify code for phone number + * The amount of gas used by the transaction. */ - type: "phone"; - }; - path?: never; - query?: never; - url: "/v1/wallets/login/code/verify"; + gasUsed?: number; + /** + * The transaction hash. + */ + hash: string; + /** + * Maximum fee per gas (EIP-1559). + */ + maxFeePerGas?: string; + /** + * Maximum priority fee per gas (EIP-1559). + */ + maxPriorityFeePerGas?: string; + /** + * The transaction nonce. + */ + nonce: number; + /** + * The transaction status (1 for success, 0 for failure). + */ + status: number; + /** + * The address that received the transaction. + */ + toAddress: string; + /** + * The index of the transaction within the block. + */ + transactionIndex: number; + /** + * The transaction type (0=legacy, 1=EIP-2930, 2=EIP-1559). + */ + transactionType?: number; + /** + * The value transferred in the transaction (in wei as string). + */ + value: string; + }>; + pagination: { + /** + * Whether there are more items available + */ + hasMore?: boolean; + /** + * Number of items per page + */ + limit?: number; + /** + * Current page number + */ + page?: number; + /** + * Total number of items available + */ + totalCount?: number; + }; + }; + }; }; -export type VerifyCodeErrors = { +export type GetContractTransactionsResponse = + GetContractTransactionsResponses[keyof GetContractTransactionsResponses]; + +export type GetContractEventsData = { + body?: never; + path: { + /** + * The blockchain network identifier where the contract is deployed. + */ + chainId: number; + /** + * The smart contract address or ENS name. + */ + address: string; + }; + query?: { + /** + * Filter by event signature hash, e.g., '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' for Transfer event + */ + signature?: string; + /** + * Filter by event topic 0 (event signature hash) + */ + filterTopic0?: string; + /** + * Filter by event topic 1 + */ + filterTopic1?: string; + /** + * Filter by event topic 2 + */ + filterTopic2?: string; + /** + * Filter by event topic 3 + */ + filterTopic3?: string; + /** + * Filter by block timestamp (Unix timestamp) greater than or equal to this value + */ + filterBlockTimestampGte?: number; + /** + * Filter by block timestamp (Unix timestamp) less than or equal to this value + */ + filterBlockTimestampLte?: number; + /** + * Filter by block number greater than or equal to this value + */ + filterBlockNumberGte?: number; + /** + * Filter by block number less than or equal to this value + */ + filterBlockNumberLte?: number; + /** + * Current page number + */ + page?: number; + /** + * Number of items per page + */ + limit?: number; + /** + * Sort order: 'asc' for ascending, 'desc' for descending + */ + sortOrder?: "asc" | "desc"; + }; + url: "/v1/contracts/{chainId}/{address}/events"; +}; + +export type GetContractEventsErrors = { /** - * Invalid OTP or request parameters + * Invalid request parameters. This occurs when the contract address or chainId format is invalid, or pagination parameters are out of range. */ 400: unknown; /** - * Internal server error + * Authentication required. The request must include a valid `x-client-id` header for frontend usage or x-secret-key for backend usage. + */ + 401: unknown; + /** + * Contract not found or no events available for the specified contract address on the given blockchain network. + */ + 404: unknown; + /** + * Internal server error. This may occur due to network connectivity issues, external service unavailability, or unexpected server errors. */ 500: unknown; }; -export type VerifyCodeResponses = { +export type GetContractEventsResponses = { /** - * OTP verified successfully + * Contract events retrieved successfully. Returns event data with metadata including pagination information. Includes decoded event parameters when ABI is available. */ 200: { - isNewUser: boolean; - token: string; - type: string; - walletAddress: string; + result: { + /** + * Array of contract events. + */ + events: Array<{ + /** + * The contract address that emitted the event. + */ + address: string; + /** + * The hash of the block containing this event. + */ + blockHash: string; + /** + * The block number where the event was emitted. + */ + blockNumber: number; + /** + * The timestamp of the block (Unix timestamp). + */ + blockTimestamp: number; + /** + * The chain ID where the event occurred. + */ + chainId: string; + /** + * The non-indexed event data as a hex string. + */ + data: string; + /** + * Decoded event data (included when ABI is available). + */ + decoded?: { + /** + * The event name. + */ + name: string; + /** + * Object containing decoded parameters. + */ + params: { + [key: string]: unknown; + }; + /** + * The event signature. + */ + signature: string; + }; + /** + * The index of the log within the transaction. + */ + logIndex: number; + /** + * Array of indexed event topics (including event signature). + */ + topics: Array; + /** + * The hash of the transaction containing this event. + */ + transactionHash: string; + /** + * The index of the transaction within the block. + */ + transactionIndex: number; + }>; + pagination: { + /** + * Whether there are more items available + */ + hasMore?: boolean; + /** + * Number of items per page + */ + limit?: number; + /** + * Current page number + */ + page?: number; + /** + * Total number of items available + */ + totalCount?: number; + }; + }; }; }; -export type VerifyCodeResponse = VerifyCodeResponses[keyof VerifyCodeResponses]; +export type GetContractEventsResponse = + GetContractEventsResponses[keyof GetContractEventsResponses]; -export type InitOauthData = { +export type GetContractMetadataData = { body?: never; - path?: never; - query: { + path: { /** - * The thirdweb project client ID + * The blockchain network identifier where the contract is deployed. */ - clientId: string; + chainId: number; /** - * The redirect URL post authentication + * The smart contract address or ENS name. */ - redirectUrl?: string; + address: string; }; - url: "/v1/wallets/login/oauth/{provider}"; + query?: never; + url: "/v1/contracts/{chainId}/{address}/metadata"; }; -export type InitOauthErrors = { +export type GetContractMetadataErrors = { /** * Invalid request parameters */ 400: unknown; /** - * Internal server error + * Authentication required. The request must include a valid `x-secret-key` header for backend authentication. */ - 500: unknown; -}; - -export type GeneratePasskeyChallengeData = { - body?: never; - path?: never; - query: { - /** - * Authentication type for passkey - either sign-up for new users or sign-in for existing users - */ - type: "sign-up" | "sign-in"; - /** - * Optional username for passkey registration - */ - username?: string; - }; - url: "/v1/wallets/login/passkey"; -}; - -export type GeneratePasskeyChallengeErrors = { + 401: unknown; /** - * Invalid request parameters + * Contract metadata not found */ - 400: unknown; + 404: unknown; + /** + * Rate limit exceeded + */ + 429: unknown; /** * Internal server error */ 500: unknown; }; -export type GeneratePasskeyChallengeResponses = { +export type GetContractMetadataResponses = { /** - * Response containing passkey challenge data + * Contract metadata from the thirdweb contract metadata service. */ 200: { - /** - * Server verification ID for the passkey challenge - */ - serverVerificationId: string; - /** - * Passkey challenge string - */ - challenge: string; - /** - * Authentication type for passkey - either sign-up for new users or sign-in for existing users - */ - type: "sign-up" | "sign-in"; + result: { + /** + * Compiler information including version. + */ + compiler?: { + /** + * Solidity compiler version used to compile the contract. + */ + version: string; + }; + /** + * Programming language of the contract (e.g., 'Solidity'). + */ + language?: string; + /** + * Compilation output including ABI and documentation. + */ + output?: { + /** + * Contract ABI (Application Binary Interface) as an array of function/event/error definitions. + */ + abi?: Array; + /** + * Developer documentation extracted from contract comments. + */ + devdoc?: { + [key: string]: unknown; + }; + /** + * User documentation extracted from contract comments. + */ + userdoc?: { + [key: string]: unknown; + }; + }; + /** + * Compilation settings including optimization and target configuration. + */ + settings?: { + /** + * Compilation target mapping source file names to contract names. + */ + compilationTarget?: { + [key: string]: string; + }; + /** + * EVM version target for compilation. + */ + evmVersion?: string; + /** + * Library addresses for linking. + */ + libraries?: { + [key: string]: unknown; + }; + /** + * Metadata settings for compilation. + */ + metadata?: { + /** + * Hash method used for bytecode metadata. + */ + bytecodeHash?: string; + }; + /** + * Optimizer settings used during compilation. + */ + optimizer?: { + /** + * Whether optimizer is enabled. + */ + enabled?: boolean; + /** + * Number of optimizer runs. + */ + runs?: number; + }; + /** + * Import remappings used during compilation. + */ + remappings?: Array; + }; + /** + * Metadata format version. + */ + version?: number; + }; }; }; -export type GeneratePasskeyChallengeResponse = - GeneratePasskeyChallengeResponses[keyof GeneratePasskeyChallengeResponses]; +export type GetContractMetadataResponse = + GetContractMetadataResponses[keyof GetContractMetadataResponses]; -export type VerifyPasskeyData = { - /** - * Request body for validating passkey authentication - */ - body?: { - /** - * Authentication type for passkey - either sign-up for new users or sign-in for existing users - */ - type: "sign-up" | "sign-in"; - /** - * Authenticator data from the passkey response - */ - authenticatorData: string; - /** - * Credential ID from the passkey response - */ - credentialId: string; - /** - * Server verification ID from the challenge - */ - serverVerificationId: string; - /** - * Client data from the passkey response - */ - clientData: string; - /** - * Origin of the request - */ - origin?: string; - /** - * Relying Party ID - */ - rpId?: string; - /** - * Signature for passkey sign in - */ - signature?: string; +export type GetContractSignaturesData = { + body?: never; + path: { /** - * Username for passkey registration + * The blockchain network identifier where the contract is deployed. */ - username?: string; + chainId: number; /** - * Credential data for passkey registration + * The smart contract address or ENS name. */ - credential?: { - /** - * Public key for the credential - */ - publicKey: string; - /** - * Algorithm used for the credential - */ - algorithm: "RS256" | "ES256"; - }; + address: string; }; - path?: never; query?: never; - url: "/v1/wallets/login/passkey/verify"; + url: "/v1/contracts/{chainId}/{address}/signatures"; }; -export type VerifyPasskeyErrors = { +export type GetContractSignaturesErrors = { /** - * Invalid passkey or request parameters + * Invalid request parameters */ 400: unknown; + /** + * Authentication required. The request must include a valid `x-secret-key` header for backend authentication. + */ + 401: unknown; + /** + * Contract metadata not found or ABI is not available + */ + 404: unknown; + /** + * Rate limit exceeded + */ + 429: unknown; /** * Internal server error */ 500: unknown; }; -export type VerifyPasskeyResponses = { +export type GetContractSignaturesResponses = { /** - * Passkey verified successfully + * Contract ABI signatures in human-readable format. These signatures can be used directly with contract interaction methods. */ 200: { - isNewUser: boolean; - token: string; - type: string; - walletAddress: string; + /** + * Array of human-readable ABI signatures including functions and events. Each signature is formatted as a string that can be used directly in contract read/write operations or event filtering. + */ + result: Array; }; }; -export type VerifyPasskeyResponse = - VerifyPasskeyResponses[keyof VerifyPasskeyResponses]; +export type GetContractSignaturesResponse = + GetContractSignaturesResponses[keyof GetContractSignaturesResponses]; -export type GenerateSiwePayloadData = { +export type GetTransactionByIdData = { body?: never; - path?: never; - query: { - /** - * The Ethereum wallet address to generate SIWE payload for - */ - address: string; + path: { /** - * The chain ID for the SIWE payload + * Unique identifier of the transaction to retrieve. */ - chainId: number; + transactionId: string; }; - url: "/v1/wallets/login/siwe"; + query?: never; + url: "/v1/transactions/{transactionId}"; }; -export type GenerateSiwePayloadErrors = { +export type GetTransactionByIdErrors = { /** - * Invalid request parameters + * Invalid request parameters. This occurs when the transaction ID format is invalid or malformed. */ 400: unknown; /** - * Internal server error + * Authentication required. The request must include a valid `x-client-id` header for frontend usage or x-secret-key for backend usage. */ - 500: unknown; -}; - -export type GenerateSiwePayloadResponses = { + 401: unknown; /** - * SIWE (Sign-In with Ethereum) payload structure + * Transaction not found. The specified transaction ID does not exist or is not associated with the authenticated client. */ - 200: { - /** - * The domain requesting the signature - */ - domain: string; - /** - * The Ethereum address performing the signing - */ - address: string; - /** - * A human-readable ASCII assertion that the user will sign - */ - statement: string; - /** - * A URI referring to the resource that is the subject of the signing - */ - uri?: string; - /** - * The current version of the SIWE Message - */ - version: string; - /** - * The Chain ID to which the session is bound - */ - chain_id?: string; - /** - * A randomized token used to prevent replay attacks - */ - nonce: string; - /** - * The time when the message was generated - */ - issued_at: string; - /** - * The time when the signed authentication message is no longer valid - */ - expiration_time: string; - /** - * The time when the signed authentication message will become valid - */ - invalid_before: string; - /** - * A list of information or references to information the user wishes to have resolved - */ - resources?: Array; - }; + 404: unknown; + /** + * Internal server error. This may occur due to engine connectivity issues, database unavailability, or unexpected server errors. + */ + 500: unknown; }; -export type GenerateSiwePayloadResponse = - GenerateSiwePayloadResponses[keyof GenerateSiwePayloadResponses]; - -export type VerifySiweSignatureData = { +export type GetTransactionByIdResponses = { /** - * Request body for verifying SIWE signature + * Transaction details retrieved successfully. Returns comprehensive transaction information including status, blockchain details, and execution metadata. */ - body?: { - /** - * The signature generated by signing the SIWE payload - */ - signature: string; - /** - * SIWE (Sign-In with Ethereum) payload structure - */ - payload: { + 200: { + result: { /** - * The domain requesting the signature + * Index within transaction batch */ - domain: string; + batchIndex: number; /** - * The Ethereum address performing the signing + * ISO timestamp when transaction was cancelled, if applicable */ - address: string; + cancelledAt: string; /** - * A human-readable ASCII assertion that the user will sign + * Blockchain network identifier as string */ - statement: string; + chainId: string; /** - * A URI referring to the resource that is the subject of the signing + * Client identifier that initiated the transaction */ - uri?: string; + clientId: string; /** - * The current version of the SIWE Message + * ISO timestamp when transaction was confirmed on-chain */ - version: string; + confirmedAt: string; /** - * The Chain ID to which the session is bound + * Block number where transaction was confirmed */ - chain_id?: string; + confirmedAtBlockNumber: string; /** - * A randomized token used to prevent replay attacks + * ISO timestamp when transaction was created */ - nonce: string; + createdAt: string; /** - * The time when the message was generated + * Additional metadata and enriched transaction information */ - issued_at: string; + enrichedData?: unknown; /** - * The time when the signed authentication message is no longer valid + * Error message if transaction failed */ - expiration_time: string; + errorMessage: string; /** - * The time when the signed authentication message will become valid + * Parameters used for transaction execution */ - invalid_before: string; + executionParams?: unknown; /** - * A list of information or references to information the user wishes to have resolved + * Result data from transaction execution */ - resources?: Array; - }; - }; - path?: never; - query?: never; - url: "/v1/wallets/login/siwe/verify"; -}; - -export type VerifySiweSignatureErrors = { - /** - * Invalid signature or request parameters - */ - 400: unknown; - /** - * Internal server error - */ - 500: unknown; -}; - -export type VerifySiweSignatureResponses = { - /** - * SIWE signature verified successfully - */ - 200: { - isNewUser: boolean; - token: string; - type: string; - walletAddress: string; + executionResult?: unknown; + /** + * Sender wallet address + */ + from: string; + /** + * Unique transaction identifier + */ + id: string; + /** + * On-chain transaction hash once confirmed + */ + transactionHash: string; + /** + * Original transaction parameters and data + */ + transactionParams?: unknown; + /** + * Transaction status + */ + status: "QUEUED" | "SUBMITTED" | "CONFIRMED" | "FAILED"; + }; }; }; -export type VerifySiweSignatureResponse = - VerifySiweSignatureResponses[keyof VerifySiweSignatureResponses]; +export type GetTransactionByIdResponse = + GetTransactionByIdResponses[keyof GetTransactionByIdResponses]; export type ListTransactionsData = { body?: never; path?: never; query?: { /** - * Filter transactions by sender wallet address. + * Filter transactions by sender wallet address or ENS name. */ from?: string; /** @@ -2451,11 +3467,11 @@ export type ListTransactionsResponses = { /** * Number of items per page */ - limit: number; + limit?: number; /** * Current page number */ - page: number; + page?: number; /** * Total number of items available */ @@ -2522,6 +3538,10 @@ export type ListTransactionsResponses = { * Original transaction parameters and data */ transactionParams?: unknown; + /** + * Transaction status + */ + status: "QUEUED" | "SUBMITTED" | "CONFIRMED" | "FAILED"; }>; }; }; @@ -2533,7 +3553,7 @@ export type ListTransactionsResponse = export type SendTransactionsData = { /** * Transaction Request - * Request object containing an array of blockchain transactions to execute. All transactions must use the same from address and chainId. Supports batching multiple transactions of different types in a single request. + * Request object containing an array of encoded blockchain transactions to execute. All transactions must use the same from address and chainId. For contract calls, use /v1/contracts/write. For native token transfers, use /v1/wallets/send. */ body?: { /** @@ -2541,69 +3561,26 @@ export type SendTransactionsData = { */ chainId: number; /** - * The wallet address that will send the transaction. + * The wallet address or ENS name that will send the transaction. */ from: string; /** - * Transaction - * A blockchain transaction of one of three supported types: contract call, encoded transaction, or native token transfer. + * Array of encoded blockchain transactions to execute. All transactions will use the same from address and chainId. */ - transactions: Array< - | { - /** - * The smart contract address to interact with. - */ - contractAddress: string; - /** - * The contract function signature to call (e.g., 'function approve(address spender, uint256 amount)'). Must start with 'function' followed by the function name and parameters as defined in the contract ABI. - */ - method: string; - /** - * Array of parameters to pass to the contract method, in the correct order and format. - */ - params?: Array; - /** - * Transaction type for smart contract method calls - */ - type: "contract-call"; - /** - * Amount of native token to send with the transaction in wei. Required for payable methods. - */ - value?: string; - } - | { - /** - * Transaction data in hexadecimal format for contract interactions or custom payloads. - */ - data: string; - /** - * The target address for the encoded transaction. - */ - to: string; - /** - * Transaction type for pre-encoded transaction data - */ - type: "encoded"; - /** - * Amount of native token to send in wei (smallest unit). Use '0' or omit for non-value transactions. - */ - value?: string; - } - | { - /** - * The recipient wallet address. - */ - to: string; - /** - * Transaction type for native token transfers - */ - type: "native-transfer"; - /** - * Amount of native token to send in wei (smallest unit). - */ - value: string; - } - >; + transactions: Array<{ + /** + * Transaction data in hexadecimal format for contract interactions or custom payloads. + */ + data: string; + /** + * The target address or ENS name for the transaction. + */ + to: string; + /** + * Amount of native token to send in wei (smallest unit). Use '0' or omit for non-value transactions. + */ + value?: string; + }>; }; path?: never; query?: never; @@ -2612,7 +3589,7 @@ export type SendTransactionsData = { export type SendTransactionsErrors = { /** - * Invalid request parameters. This occurs when transaction parameters are malformed, insufficient balance, invalid contract data, or unsupported transaction type. + * Invalid request parameters. This occurs when transaction data is malformed, insufficient balance, or invalid encoded data. */ 400: unknown; /** @@ -2620,14 +3597,14 @@ export type SendTransactionsErrors = { */ 401: unknown; /** - * Internal server error. This may occur due to blockchain connectivity issues, gas estimation failures, contract execution errors, or unexpected server errors. + * Internal server error. This may occur due to blockchain connectivity issues, gas estimation failures, or unexpected server errors. */ 500: unknown; }; export type SendTransactionsResponses = { /** - * Transaction submitted successfully. Returns the transaction ID for tracking and monitoring. + * Encoded transactions submitted successfully. Returns the transaction IDs for tracking and monitoring. */ 200: { result: { @@ -2642,133 +3619,285 @@ export type SendTransactionsResponses = { export type SendTransactionsResponse = SendTransactionsResponses[keyof SendTransactionsResponses]; -export type GetTransactionByIdData = { - body?: never; - path: { +export type CreatePaymentData = { + /** + * Create Product Request + * Request to create a product to be purchased. Users can purchase the product via hosted UI (link is returned), a transaction execution referencing the product ID, or embedded widgets with the product ID. + */ + body?: { /** - * Unique identifier of the transaction to retrieve. + * The name of the product */ - transactionId: string; + name: string; + /** + * The description of the product + */ + description: string; + /** + * The URL of the product image + */ + imageUrl?: string; + /** + * The token to purchase + */ + token: { + /** + * The token address to purchase (use 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE for native token) + */ + address: string; + /** + * The blockchain network where the token is located + */ + chainId: number; + /** + * The amount of the token to purchase in wei. + */ + amount: string; + }; + /** + * The wallet address or ENS name that will receive the payment for the product + */ + recipient: string; + /** + * App specific purchase data for this payment + */ + purchaseData?: unknown; }; + path?: never; query?: never; - url: "/v1/transactions/{transactionId}"; + url: "/v1/payments"; }; -export type GetTransactionByIdErrors = { +export type CreatePaymentErrors = { /** - * Invalid request parameters. This occurs when the transaction ID format is invalid or malformed. + * Invalid request parameters. */ 400: unknown; /** - * Authentication required. The request must include a valid `x-client-id` header for frontend usage or x-secret-key for backend usage. + * Authentication required. For backend usage, include `x-secret-key` header. For frontend usage, include `x-client-id` + `Authorization: Bearer ` headers. */ 401: unknown; /** - * Transaction not found. The specified transaction ID does not exist or is not associated with the authenticated client. + * Payment required. Insufficient wallet balance to complete the purchase. */ - 404: unknown; + 402: unknown; /** - * Internal server error. This may occur due to engine connectivity issues, database unavailability, or unexpected server errors. + * Internal server error. This may occur due to network connectivity issues, wallet creation failures, or transaction execution failures. */ 500: unknown; }; -export type GetTransactionByIdResponses = { +export type CreatePaymentResponses = { /** - * Transaction details retrieved successfully. Returns comprehensive transaction information including status, blockchain details, and execution metadata. + * Create Payment Response + * Successful payment creation response containing the payment ID and link to purchase the product */ 200: { result: { /** - * Index within transaction batch - */ - batchIndex: number; - /** - * ISO timestamp when transaction was cancelled, if applicable - */ - cancelledAt: string; - /** - * Blockchain network identifier as string + * The payment ID */ - chainId: string; + id: string; /** - * Client identifier that initiated the transaction + * The link to purchase the product */ + link: string; + }; + }; +}; + +export type CreatePaymentResponse = + CreatePaymentResponses[keyof CreatePaymentResponses]; + +export type GetPaymentHistoryData = { + body?: never; + path: { + id: string; + }; + query?: never; + url: "/v1/payments/{id}"; +}; + +export type GetPaymentHistoryErrors = { + /** + * Bad request + */ + 400: { + error: string; + }; + /** + * Payment link not found + */ + 404: { + error: string; + }; +}; + +export type GetPaymentHistoryError = + GetPaymentHistoryErrors[keyof GetPaymentHistoryErrors]; + +export type GetPaymentHistoryResponses = { + /** + * Payment history retrieved successfully + */ + 200: { + /** + * List of payments for the client + */ + data: Array<{ + id: string; + blockNumber?: string; + transactionId?: string; + onrampId?: string; clientId: string; /** - * ISO timestamp when transaction was confirmed on-chain + * A valid Ethereum address (0x-prefixed hex string) or ENS name (e.g., vitalik.eth). */ - confirmedAt: string; + sender?: string; /** - * Block number where transaction was confirmed + * A valid Ethereum address (0x-prefixed hex string) or ENS name (e.g., vitalik.eth). */ - confirmedAtBlockNumber: string; + receiver: string; /** - * ISO timestamp when transaction was created + * A valid Ethereum address (0x-prefixed hex string) or ENS name (e.g., vitalik.eth). */ + developerFeeRecipient?: string; + developerFeeBps?: number; + transactions: Array<{ + chainId: number; + transactionHash: string; + }>; + status: "PENDING" | "COMPLETED" | "FAILED" | "NOT_FOUND"; + type: "buy" | "sell" | "transfer" | "onramp"; + originAmount?: string; + destinationAmount: string; + paymentLinkId?: string; + purchaseData?: unknown; + originToken?: { + chainId: number; + /** + * A valid Ethereum address (0x-prefixed hex string) or ENS name (e.g., vitalik.eth). + */ + address: string; + symbol: string; + name: string; + decimals: number; + iconUri?: string; + }; + destinationToken: { + chainId: number; + /** + * A valid Ethereum address (0x-prefixed hex string) or ENS name (e.g., vitalik.eth). + */ + address: string; + symbol: string; + name: string; + decimals: number; + iconUri?: string; + }; createdAt: string; + }>; + meta: { /** - * Additional metadata and enriched transaction information - */ - enrichedData?: unknown; - /** - * Error message if transaction failed - */ - errorMessage: string; - /** - * Parameters used for transaction execution - */ - executionParams?: unknown; - /** - * Result data from transaction execution - */ - executionResult?: unknown; - /** - * Sender wallet address - */ - from: string; - /** - * Unique transaction identifier - */ - id: string; - /** - * On-chain transaction hash once confirmed + * Total number of payments */ - transactionHash: string; + totalCount: number; + }; + }; +}; + +export type GetPaymentHistoryResponse = + GetPaymentHistoryResponses[keyof GetPaymentHistoryResponses]; + +export type PaymentsPurchaseData = { + /** + * Purchase Product Request + * Request to purchase a product. The system will automatically use your wallet balance to purchase the specified product. + */ + body?: { + /** + * The wallet address or ENS name that will purchase the product. + */ + from: string; + }; + path: { + id: string; + }; + query?: never; + url: "/v1/payments/{id}"; +}; + +export type PaymentsPurchaseErrors = { + /** + * Invalid request parameters. + */ + 400: unknown; + /** + * Authentication required. For backend usage, include `x-secret-key` header. For frontend usage, include `x-client-id` + `Authorization: Bearer ` headers. + */ + 401: unknown; + /** + * Payment required. Insufficient wallet balance to complete the purchase. + */ + 402: unknown; + /** + * Internal server error. This may occur due to network connectivity issues, wallet creation failures, or transaction execution failures. + */ + 500: unknown; +}; + +export type PaymentsPurchaseResponses = { + /** + * Product purchased successfully. Returns the transaction used for the purchase. + */ + 200: { + result: { /** - * Original transaction parameters and data + * Transaction ID that was executed for your product purchase */ - transactionParams?: unknown; + transactionId: string; }; }; }; -export type GetTransactionByIdResponse = - GetTransactionByIdResponses[keyof GetTransactionByIdResponses]; +export type PaymentsPurchaseResponse = + PaymentsPurchaseResponses[keyof PaymentsPurchaseResponses]; -export type SignMessageData = { - body?: { +export type ListTokensData = { + body?: never; + path?: never; + query?: { /** - * The blockchain network identifier where the signing will occur. Common values include: 1 (Ethereum), 137 (Polygon), 56 (BSC). + * Number of tokens to return per page (1-100). */ - chainId: number; + limit?: number; /** - * The wallet address that will sign the message. + * Page number for pagination, starting from 1. */ - from: string; + page?: number; /** - * The message to be signed. Can be plain text or hexadecimal format (starting with 0x). The format is automatically detected. + * Limit tokens to a specific chain. */ - message: string; + chainId?: number; + /** + * Get a specific token by contract address + */ + tokenAddress?: string; + /** + * Limit tokens to a specific symbol. + */ + symbol?: string; + /** + * Limit tokens to a specific name. + */ + name?: string; }; - path?: never; - query?: never; - url: "/v1/sign/message"; + url: "/v1/tokens"; }; -export type SignMessageErrors = { +export type ListTokensErrors = { /** - * Invalid request parameters. This occurs when the wallet address format is invalid, chainId is not supported, or the message format is incorrect. + * Invalid request parameters. */ 400: unknown; /** @@ -2776,220 +3905,314 @@ export type SignMessageErrors = { */ 401: unknown; /** - * Internal server error. This may occur due to wallet connectivity issues, signing service unavailability, or unexpected server errors. + * Internal server error. This may occur due to network connectivity issues, wallet creation failures, or transaction execution failures. */ 500: unknown; }; -export type SignMessageResponses = { +export type ListTokensResponses = { /** - * Message signed successfully. Returns the cryptographic signature that can be used for verification. + * Tokens returned successfully. */ 200: { - result: { + pagination: { /** - * The cryptographic signature in hexadecimal format. This can be used for verification and authentication purposes. + * Whether there are more items available */ - signature: string; + hasMore?: boolean; + /** + * Number of items per page + */ + limit?: number; + /** + * Current page number + */ + page?: number; + /** + * Total number of items available + */ + totalCount?: number; }; + tokens: Array<{ + /** + * The blockchain network identifier. Common values include: 1 (Ethereum), 8453 (Base), 137 (Polygon), 56 (BSC), 43114 (Avalanche), 42161 (Arbitrum), 10 (Optimism). + */ + chainId: number; + /** + * A valid Ethereum address (0x-prefixed hex string) or ENS name (e.g., vitalik.eth). + */ + address: string; + decimals: number; + symbol: string; + iconUri?: string; + /** + * Token price in different FIAT currencies. + */ + prices: { + [key: string]: number; + }; + }>; }; }; -export type SignMessageResponse = - SignMessageResponses[keyof SignMessageResponses]; +export type ListTokensResponse = ListTokensResponses[keyof ListTokensResponses]; -export type SignTypedDataData = { +export type CreateTokenData = { + /** + * Request schema for creating a new ERC20 token + */ body?: { /** - * The blockchain network identifier for EIP-712 domain separation. + * The blockchain network identifier. Common values include: 1 (Ethereum), 8453 (Base), 137 (Polygon), 56 (BSC), 43114 (Avalanche), 42161 (Arbitrum), 10 (Optimism). */ chainId: number; /** - * EIP-712 domain separator containing contract and chain information for signature verification. + * Token name */ - domain: { + name: string; + /** + * Token symbol + */ + symbol: string; + /** + * Token description + */ + description: string; + /** + * Token image URL + */ + imageUrl: string; + /** + * Wallet address or ENS that will deploy the token. + */ + from: string; + /** + * The token owner address, if different from `from`. + */ + owner?: string; + /** + * A salt to deterministically generate the token address. + */ + salt?: string; + /** + * The maximum token supply. + */ + maxSupply?: number; + /** + * Setup this token for a sale. + */ + sale?: { + type?: "pool"; /** - * Chain ID as string for domain separation + * The initial token price in wei. This price is in the currency specified by `currency` (or the native token if not specified). */ - chainId?: string; + startingPrice: string; /** - * The domain name (e.g., token name) + * The number of tokens to allocate to the sale. */ - name?: string; + amount: number; /** - * Optional salt for additional entropy + * The bps fee on the token pool. */ - salt?: string; + developerFeeBps?: number; /** - * The contract address that will verify this signature + * The address to send the developer fee to. Defaults to the token owner. */ - verifyingContract?: string; + developerFeeRecipient?: string; /** - * Domain version for signature compatibility + * The currency to price this token sale in. Defaults to the native token. */ - version?: string; - }; - /** - * The wallet address that will sign the typed data. - */ - from: string; - /** - * The structured data to be signed, matching the defined types schema. - */ - message: { - [key: string]: unknown; - }; - /** - * The primary type name from the types object that defines the main structure being signed. - */ - primaryType: string; - /** - * Type definitions for the structured data, following EIP-712 specifications. - */ - types: { - [key: string]: Array<{ - /** - * The field name - */ - name: string; - /** - * The Solidity type (e.g., 'address', 'uint256') - */ - type: string; - }>; + currency?: string; }; }; path?: never; query?: never; - url: "/v1/sign/typed-data"; + url: "/v1/tokens"; }; -export type SignTypedDataErrors = { +export type CreateTokenErrors = { /** - * Invalid request parameters. This occurs when the typed data structure is malformed, domain parameters are incorrect, or wallet address format is invalid. + * Invalid request parameters. */ 400: unknown; /** - * Authentication required. The request must include valid `x-wallet-access-token` headers for accessing the wallet, as well as a x-client-id (frontend) or x-secret-key (backend) for project authentication. + * Authentication required. For backend usage, include `x-secret-key` header. For frontend usage, include `x-client-id` + `Authorization: Bearer ` headers. */ 401: unknown; /** - * Internal server error. This may occur due to wallet connectivity issues, signing service unavailability, or unexpected server errors. + * Payment required. Insufficient wallet balance to deploy the contract. + */ + 402: unknown; + /** + * Internal server error. This may occur due to network connectivity issues, wallet creation failures, or transaction execution failures. */ 500: unknown; }; -export type SignTypedDataResponses = { +export type CreateTokenResponses = { /** - * Typed data signed successfully. Returns the EIP-712 compliant signature that can be used for on-chain verification. + * The token is being deployed. Returns the predicted token address. */ - 200: { - result: { - /** - * The cryptographic signature in hexadecimal format. This can be used for verification and authentication purposes. - */ - signature: string; - }; + 202: { + /** + * The in-progress deployment transaction ID. + */ + transactionId: string; + /** + * The address the token was deployed at + */ + address: string; }; }; -export type SignTypedDataResponse = - SignTypedDataResponses[keyof SignTypedDataResponses]; +export type CreateTokenResponse = + CreateTokenResponses[keyof CreateTokenResponses]; -export type BuyTokenWithUsdData = { - /** - * Buy Token Request - * Request to buy tokens using a USD amount. The system will automatically use your wallet balance to purchase the specified tokens. - */ - body?: { +export type GetTokenOwnersData = { + body?: never; + path: { /** - * The USD amount to spend on the token purchase (as string to support decimals) + * The blockchain network identifier. Common values include: 1 (Ethereum), 8453 (Base), 137 (Polygon), 56 (BSC), 43114 (Avalanche), 42161 (Arbitrum), 10 (Optimism). */ - amountUsd: string; + chainId: number; /** - * The blockchain network where the token will be received + * A valid Ethereum address (0x-prefixed hex string) or ENS name (e.g., vitalik.eth). */ - chainId: number; + address: string; + }; + query?: { /** - * The wallet address that will buy the tokens. + * Number of owners to return per page (1-100). */ - from: string; + limit?: number; /** - * The token address to purchase (use 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE for native token) + * Page number for pagination, starting from 1. */ - tokenAddress: string; + page?: number; }; - path?: never; - query?: never; - url: "/v1/tokens/buy"; + url: "/v1/tokens/{chainId}/{address}/owners"; }; -export type BuyTokenWithUsdErrors = { +export type GetTokenOwnersErrors = { /** * Invalid request parameters. */ 400: unknown; /** - * Authentication required. For backend usage, include `x-secret-key` header. For frontend usage, include `x-client-id` + `Authorization: Bearer ` headers. + * Authentication required. The request must include a valid `x-client-id` header for frontend usage or x-secret-key for backend usage. */ 401: unknown; /** - * Payment required. Insufficient wallet balance to complete the purchase. + * Token not found or no owners available. */ - 402: unknown; + 404: unknown; /** - * Internal server error. This may occur due to network connectivity issues, wallet creation failures, or transaction execution failures. + * Internal server error. */ 500: unknown; }; -export type BuyTokenWithUsdResponses = { +export type GetTokenOwnersResponses = { /** - * Buy Token Response - * Successful token purchase response containing executed transaction IDs + * Token owners retrieved successfully. Returns owners with pagination information. */ 200: { result: { /** - * Transaction IDs that were executed for your token purchase + * Array of token owners with amounts. */ - transactionIds: Array; + owners: Array<{ + /** + * Owner wallet address + */ + address: string; + /** + * Token amount owned as a string + */ + amount: string; + }>; + pagination: { + /** + * Whether there are more items available + */ + hasMore?: boolean; + /** + * Number of items per page + */ + limit?: number; + /** + * Current page number + */ + page?: number; + /** + * Total number of items available + */ + totalCount?: number; + }; }; }; }; -export type BuyTokenWithUsdResponse = - BuyTokenWithUsdResponses[keyof BuyTokenWithUsdResponses]; +export type GetTokenOwnersResponse = + GetTokenOwnersResponses[keyof GetTokenOwnersResponses]; -export type SellTokenForUsdData = { +export type BridgeSwapData = { /** - * Sell Token Request - * Request to sell tokens for USD value. The system will automatically convert your tokens to USDC on Arbitrum. + * Swap Token Request + * Request to swap tokens 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. */ body?: { /** - * The USD amount worth of tokens to sell (as string to support decimals) - */ - amountUsd: string; - /** - * The blockchain network where the token is located + * Whether to swap the exact input or output amount */ - chainId: number; + exact?: "input" | "output"; + tokenIn: { + /** + * The input token address to swap (use 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE for native token) + */ + address: string; + /** + * The blockchain network where the token is located + */ + chainId: number; + /** + * The amount of the input token to swap in wei. + */ + amount?: string; + /** + * The maximum amount of the input token to swap in wei. + */ + maxAmount?: string; + }; + tokenOut: { + /** + * The output token address to swap (use 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE for native token) + */ + address: string; + /** + * The blockchain network where the token is located + */ + chainId: number; + /** + * The amount of the output token to receive in wei. + */ + amount?: string; + /** + * The minimum amount of the output token to receive in wei. + */ + minAmount?: string; + }; /** - * The wallet address that will send the transaction. + * The wallet address or ENS name that will execute the swap. */ from: string; - /** - * The token address to sell (use 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE for native token) - */ - tokenAddress: string; }; path?: never; query?: never; - url: "/v1/tokens/sell"; + url: "/v1/bridge/swap"; }; -export type SellTokenForUsdErrors = { +export type BridgeSwapErrors = { /** * Invalid request parameters. */ @@ -2999,7 +4222,7 @@ export type SellTokenForUsdErrors = { */ 401: unknown; /** - * Payment required. Insufficient token balance to complete the sale. + * Payment required. Insufficient wallet balance to complete the purchase. */ 402: unknown; /** @@ -3008,93 +4231,197 @@ export type SellTokenForUsdErrors = { 500: unknown; }; -export type SellTokenForUsdResponses = { +export type BridgeSwapResponses = { /** - * Sell Token Response - * Successful token sale response containing executed transaction IDs + * Swap Token Response + * Successful token swap response containing executed transaction ID */ 200: { result: { /** - * Transaction IDs that were executed for your token sale + * Payment transaction ID that was executed */ - transactionIds: Array; + transactionId: string; }; }; }; -export type SellTokenForUsdResponse = - SellTokenForUsdResponses[keyof SellTokenForUsdResponses]; +export type BridgeSwapResponse = BridgeSwapResponses[keyof BridgeSwapResponses]; -export type TransferTokenWithUsdData = { +export type ChatData = { /** - * Transfer Token Request - * Request to transfer tokens worth a USD amount to another wallet address. The system will calculate the token amount based on current prices and transfer the tokens. + * Chat Request + * Chat request */ body?: { /** - * The USD amount worth of tokens to transfer (as string to support decimals) + * Natural language query for the AI assistant */ - amountUsd: string; - /** - * The blockchain network where the token is located - */ - chainId: number; - /** - * The wallet address that will send the transaction. - */ - from: string; + messages: Array<{ + role: "user" | "assistant" | "system" | "tool"; + content: + | string + | Array< + | { + type: "image"; + image_url?: string; + b64?: string; + } + | { + type: "text"; + text: string; + } + | { + type: "transaction"; + chain_id: number; + transaction_hash: string; + } + >; + }>; /** - * The wallet address that will receive the transferred tokens + * Context for the AI assistant */ - to: string; + context?: { + /** + * Optional wallet address that will execute transactions + */ + from?: string; + /** + * Optional chain IDs for context + */ + chain_ids?: Array; + /** + * Optional session ID for conversation continuity. If not provided, a new session will be created + */ + session_id?: string; + /** + * Whether to automatically execute transactions. If not provided, the default is false + */ + auto_execute_transactions?: boolean; + }; /** - * The token address to transfer (use 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE for native token) + * Enable server streaming of the AI response */ - tokenAddress: string; + stream?: boolean; }; path?: never; query?: never; - url: "/v1/tokens/transfer"; + url: "/ai/chat"; }; -export type TransferTokenWithUsdErrors = { +export type ChatResponses = { /** - * Invalid request parameters or insufficient token balance. + * Chat Response + * Chat response */ - 400: unknown; - /** - * Authentication required. For backend usage, include `x-secret-key` header. For frontend usage, include `x-client-id` + `Authorization: Bearer ` headers. - */ - 401: unknown; - /** - * Payment required. Insufficient wallet balance to complete the transfer. - */ - 402: unknown; + 200: { + /** + * The AI assistant's response + */ + message: string; + actions: Array< + | { + session_id: string; + request_id: string; + source?: string; + type: "sign_transaction"; + data: { + chain_id: number; + function?: string; + to: string; + value: string; + data: string; + }; + } + | { + session_id: string; + request_id: string; + source?: string; + type: "sign_swap"; + data: { + transaction: { + chain_id: number; + function?: string; + to: string; + value: string; + data: string; + }; + action: string; + intent: { + origin_chain_id: number; + origin_token_address: string; + destination_chain_id: number; + destination_token_address: string; + amount: string; + sender: string; + receiver: string; + maxSteps: number; + }; + from_token: { + address: string; + chain_id: number; + amount: string; + symbol: string; + decimals: number; + price: number; + }; + to_token: { + address: string; + chain_id: number; + amount: string; + symbol: string; + decimals: number; + price: number; + }; + }; + } + | { + session_id: string; + request_id: string; + source?: string; + type: "monitor_transaction"; + data: { + transaction_id: string; + }; + } + >; + session_id: string; + request_id: string; + }; +}; + +export type ChatResponse = ChatResponses[keyof ChatResponses]; + +export type McpServerData = { + body?: unknown; + path?: never; + query?: never; + url: "/mcp"; +}; + +export type McpServerResponses = { /** - * Internal server error. This may occur due to network connectivity issues, wallet creation failures, or transaction execution failures. + * MCP response */ - 500: unknown; + 200: unknown; +}; + +export type LlmsTxtData = { + body?: never; + path?: never; + query?: never; + url: "/llms.txt"; }; -export type TransferTokenWithUsdResponses = { +export type LlmsTxtResponses = { /** - * Transfer Token Response - * Successful token transfer response containing executed transaction IDs + * LLMs.txt */ - 200: { - result: { - /** - * Transaction IDs that were executed for your token transfer - */ - transactionIds: Array; - }; - }; + 200: string; }; -export type TransferTokenWithUsdResponse = - TransferTokenWithUsdResponses[keyof TransferTokenWithUsdResponses]; +export type LlmsTxtResponse = LlmsTxtResponses[keyof LlmsTxtResponses]; export type ClientOptions = { - baseUrl: "https://api.thirdweb.com" | "http://localhost:3030" | (string & {}); + baseUrl: "https://api.thirdweb.com" | (string & {}); }; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fa41e6f6cdd..7f2ab4f04ae 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -130,6 +130,9 @@ importers: '@tanstack/react-table': specifier: ^8.21.3 version: 8.21.3(react-dom@19.1.0(react@19.1.0))(react@19.1.0) + '@thirdweb-dev/api': + specifier: workspace:* + version: link:../../packages/api '@thirdweb-dev/service-utils': specifier: workspace:* version: link:../../packages/service-utils @@ -18079,7 +18082,7 @@ snapshots: '@babel/code-frame': 7.27.1 '@babel/generator': 7.28.0 '@babel/helper-globals': 7.28.0 - '@babel/parser': 7.28.0 + '@babel/parser': 7.28.3 '@babel/template': 7.27.2 '@babel/types': 7.28.2 debug: 4.4.1(supports-color@8.1.1) @@ -31298,7 +31301,7 @@ snapshots: istanbul-lib-instrument@5.2.1: dependencies: '@babel/core': 7.28.0 - '@babel/parser': 7.28.0 + '@babel/parser': 7.28.3 '@istanbuljs/schema': 0.1.3 istanbul-lib-coverage: 3.2.2 semver: 7.7.2 @@ -32340,7 +32343,7 @@ snapshots: dependencies: '@babel/core': 7.28.0 '@babel/generator': 7.28.0 - '@babel/parser': 7.28.0 + '@babel/parser': 7.28.3 '@babel/types': 7.28.2 flow-enums-runtime: 0.0.6 metro: 0.81.4(bufferutil@4.0.9)(utf-8-validate@5.0.10) From c2934ce52ddd7057e4773eb275389e16b642723b Mon Sep 17 00:00:00 2001 From: 0xFirekeeper <0xFirekeeper@gmail.com> Date: Fri, 5 Sep 2025 04:42:27 +0700 Subject: [PATCH 2/6] Refactor API host constant usage Moved THIRDWEB_API_HOST definition to a shared constants file and updated imports in searchUsers and useEmbeddedWallets to use the centralized constant. This improves maintainability and consistency across the codebase. --- .../@/components/in-app-wallet-users-content/searchUsers.ts | 3 +-- apps/dashboard/src/@/constants/urls.ts | 5 ++--- apps/dashboard/src/@/hooks/useEmbeddedWallets.ts | 3 +-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/apps/dashboard/src/@/components/in-app-wallet-users-content/searchUsers.ts b/apps/dashboard/src/@/components/in-app-wallet-users-content/searchUsers.ts index 9d5720eb291..36fe6882b5e 100644 --- a/apps/dashboard/src/@/components/in-app-wallet-users-content/searchUsers.ts +++ b/apps/dashboard/src/@/components/in-app-wallet-users-content/searchUsers.ts @@ -4,11 +4,10 @@ import type { } from "@thirdweb-dev/api"; import { configure, listUserWallets } from "@thirdweb-dev/api"; import type { WalletUser } from "thirdweb/wallets"; +import { THIRDWEB_API_HOST } from "@/constants/urls"; import type { SearchType } from "./types"; // Configure the API client to use the correct base URL -const THIRDWEB_API_HOST = - process.env.NEXT_PUBLIC_THIRDWEB_API_HOST || "https://api.thirdweb.com"; configure({ override: { baseUrl: THIRDWEB_API_HOST, diff --git a/apps/dashboard/src/@/constants/urls.ts b/apps/dashboard/src/@/constants/urls.ts index de45290961c..82e5cfb442e 100644 --- a/apps/dashboard/src/@/constants/urls.ts +++ b/apps/dashboard/src/@/constants/urls.ts @@ -1,6 +1,5 @@ -export const THIRDWEB_EWS_API_HOST = - process.env.NEXT_PUBLIC_THIRDWEB_EWS_API_HOST || - "https://in-app-wallet.thirdweb.com"; +export const THIRDWEB_API_HOST = + process.env.NEXT_PUBLIC_THIRDWEB_API_HOST || "https://api.thirdweb.com"; export const THIRDWEB_PAY_DOMAIN = process.env.NEXT_PUBLIC_PAY_URL || "pay.thirdweb-dev.com"; diff --git a/apps/dashboard/src/@/hooks/useEmbeddedWallets.ts b/apps/dashboard/src/@/hooks/useEmbeddedWallets.ts index 227db779e1f..986cec3a2c8 100644 --- a/apps/dashboard/src/@/hooks/useEmbeddedWallets.ts +++ b/apps/dashboard/src/@/hooks/useEmbeddedWallets.ts @@ -6,11 +6,10 @@ import type { import { configure, listUserWallets } from "@thirdweb-dev/api"; import { useActiveAccount } from "thirdweb/react"; import type { WalletUser } from "thirdweb/wallets"; +import { THIRDWEB_API_HOST } from "@/constants/urls"; import { embeddedWalletsKeys } from "../query-keys/cache-keys"; // Configure the API client to use the correct base URL -const THIRDWEB_API_HOST = - process.env.NEXT_PUBLIC_THIRDWEB_API_HOST || "https://api.thirdweb.com"; configure({ override: { baseUrl: THIRDWEB_API_HOST, From 591f9a9fca688f4af2cbd1bdf3071ec57702d8a3 Mon Sep 17 00:00:00 2001 From: 0xFirekeeper <0xFirekeeper@gmail.com> Date: Fri, 5 Sep 2025 04:43:15 +0700 Subject: [PATCH 3/6] Update default THIRDWEB_API_HOST URL Changed the fallback THIRDWEB_API_HOST from 'https://api.thirdweb.com' to 'https://api.thirdweb-dev.com' to reflect the new API endpoint. --- apps/dashboard/src/@/constants/urls.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/dashboard/src/@/constants/urls.ts b/apps/dashboard/src/@/constants/urls.ts index 82e5cfb442e..fc30a7f78b2 100644 --- a/apps/dashboard/src/@/constants/urls.ts +++ b/apps/dashboard/src/@/constants/urls.ts @@ -1,5 +1,5 @@ export const THIRDWEB_API_HOST = - process.env.NEXT_PUBLIC_THIRDWEB_API_HOST || "https://api.thirdweb.com"; + process.env.NEXT_PUBLIC_THIRDWEB_API_HOST || "https://api.thirdweb-dev.com"; export const THIRDWEB_PAY_DOMAIN = process.env.NEXT_PUBLIC_PAY_URL || "pay.thirdweb-dev.com"; From 51fe8c44154e096af09f4170935f77dbad5a702f Mon Sep 17 00:00:00 2001 From: 0xFirekeeper <0xFirekeeper@gmail.com> Date: Fri, 5 Sep 2025 04:50:07 +0700 Subject: [PATCH 4/6] Add @thirdweb-dev/api to ignored dependencies in knip.json Updated the knip.json configuration to include @thirdweb-dev/api in the ignoreDependencies list for the dashboard app. --- apps/dashboard/knip.json | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/dashboard/knip.json b/apps/dashboard/knip.json index 0daf302b2a4..03076122bc2 100644 --- a/apps/dashboard/knip.json +++ b/apps/dashboard/knip.json @@ -8,6 +8,7 @@ ], "ignoreBinaries": ["only-allow"], "ignoreDependencies": [ + "@thirdweb-dev/api", "@thirdweb-dev/service-utils", "@thirdweb-dev/vault-sdk", "thirdweb", From 229aeb23a4840f88847df1f84415039c0320912b Mon Sep 17 00:00:00 2001 From: 0xFirekeeper <0xFirekeeper@gmail.com> Date: Fri, 5 Sep 2025 05:07:05 +0700 Subject: [PATCH 5/6] Add pagination support to embedded wallets fetching Enhanced the fetchAccountList function and related hooks to handle paginated API responses using the hasMore flag. This ensures all wallet users are fetched across multiple pages, improving reliability and scalability of wallet data retrieval. --- .../src/@/hooks/useEmbeddedWallets.ts | 343 +++++++++--------- 1 file changed, 173 insertions(+), 170 deletions(-) diff --git a/apps/dashboard/src/@/hooks/useEmbeddedWallets.ts b/apps/dashboard/src/@/hooks/useEmbeddedWallets.ts index 986cec3a2c8..1e529c05a72 100644 --- a/apps/dashboard/src/@/hooks/useEmbeddedWallets.ts +++ b/apps/dashboard/src/@/hooks/useEmbeddedWallets.ts @@ -1,7 +1,7 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; import type { - ListUserWalletsData, - ListUserWalletsResponses, + ListUserWalletsData, + ListUserWalletsResponses, } from "@thirdweb-dev/api"; import { configure, listUserWallets } from "@thirdweb-dev/api"; import { useActiveAccount } from "thirdweb/react"; @@ -11,9 +11,9 @@ import { embeddedWalletsKeys } from "../query-keys/cache-keys"; // Configure the API client to use the correct base URL configure({ - override: { - baseUrl: THIRDWEB_API_HOST, - }, + override: { + baseUrl: THIRDWEB_API_HOST, + }, }); // Extract types from the generated API @@ -21,189 +21,192 @@ type APIWallet = ListUserWalletsResponses[200]["result"]["wallets"][0]; type APIProfile = APIWallet["profiles"][0]; const fetchAccountList = ({ - jwt, - clientId, - ecosystemSlug, - teamId, - pageNumber, + jwt, + clientId, + ecosystemSlug, + teamId, + pageNumber, }: { - jwt: string; - clientId?: string; - ecosystemSlug?: string; - teamId: string; - pageNumber: number; + jwt: string; + clientId?: string; + ecosystemSlug?: string; + teamId: string; + pageNumber: number; }) => { - return async () => { - try { - // Prepare query parameters for the new API - const queryParams: ListUserWalletsData["query"] = { - page: pageNumber, - limit: 50, // Keep the same page size - }; - - // Use the generated API function with Bearer authentication - const response = await listUserWallets({ - query: queryParams, - headers: { - Authorization: `Bearer ${jwt}`, - "Content-Type": "application/json", - "x-thirdweb-team-id": teamId, - ...(clientId && { "x-client-id": clientId }), - ...(ecosystemSlug && { - "x-ecosystem-id": `ecosystem.${ecosystemSlug}`, - }), - }, - }); - - // Handle response - if (response.error || !response.data) { - const errorMessage = - typeof response.error === "string" - ? response.error - : "No data returned"; - throw new Error(errorMessage); - } - - // Transform the response to match the expected format - return { - users: response.data.result.wallets.map(transformToWalletUser), - }; - } catch (error) { - console.error("Failed to fetch wallets:", error); - throw error; - } - }; + return async () => { + try { + // Prepare query parameters for the new API + const queryParams: ListUserWalletsData["query"] = { + page: pageNumber, + limit: 50, // Keep the same page size + }; + + // Use the generated API function with Bearer authentication + const response = await listUserWallets({ + query: queryParams, + headers: { + Authorization: `Bearer ${jwt}`, + "Content-Type": "application/json", + "x-thirdweb-team-id": teamId, + ...(clientId && { "x-client-id": clientId }), + ...(ecosystemSlug && { + "x-ecosystem-id": `ecosystem.${ecosystemSlug}`, + }), + }, + }); + + // Handle response + if (response.error || !response.data) { + const errorMessage = + typeof response.error === "string" + ? response.error + : "No data returned"; + throw new Error(errorMessage); + } + + // Transform the response to match the expected format + return { + users: response.data.result.wallets.map(transformToWalletUser), + hasMore: response.data.result.pagination.hasMore ?? false, + }; + } catch (error) { + console.error("Failed to fetch wallets:", error); + throw error; + } + }; }; // Transform API response to match existing WalletUser format function transformToWalletUser(apiWallet: APIWallet): WalletUser { - return { - id: getProfileId(apiWallet.profiles[0]) || "", - linkedAccounts: apiWallet.profiles.map((profile) => { - // Create details object based on the profile data - let details: - | { email: string; [key: string]: string } - | { phone: string; [key: string]: string } - | { address: string; [key: string]: string } - | { id: string; [key: string]: string }; - - const profileId = getProfileId(profile); - - if ("email" in profile && profile.email) { - details = { email: profile.email, id: profileId }; - } else if ("phone" in profile && profile.phone) { - details = { phone: profile.phone, id: profileId }; - } else if ("walletAddress" in profile && profile.walletAddress) { - details = { address: profile.walletAddress, id: profileId }; - } else { - details = { id: profileId }; - } - - return { - type: profile.type, - details, - }; - }), - wallets: apiWallet.address - ? [ - { - address: apiWallet.address, - createdAt: apiWallet.createdAt || new Date().toISOString(), - type: "enclave" as const, - }, - ] - : [], - }; + return { + id: getProfileId(apiWallet.profiles[0]) || "", + linkedAccounts: apiWallet.profiles.map((profile) => { + // Create details object based on the profile data + let details: + | { email: string; [key: string]: string } + | { phone: string; [key: string]: string } + | { address: string; [key: string]: string } + | { id: string; [key: string]: string }; + + const profileId = getProfileId(profile); + + if ("email" in profile && profile.email) { + details = { email: profile.email, id: profileId }; + } else if ("phone" in profile && profile.phone) { + details = { phone: profile.phone, id: profileId }; + } else if ("walletAddress" in profile && profile.walletAddress) { + details = { address: profile.walletAddress, id: profileId }; + } else { + details = { id: profileId }; + } + + return { + type: profile.type, + details, + }; + }), + wallets: apiWallet.address + ? [ + { + address: apiWallet.address, + createdAt: apiWallet.createdAt || new Date().toISOString(), + type: "enclave" as const, + }, + ] + : [], + }; } // Helper function to safely get ID from any profile type function getProfileId(profile: APIProfile | undefined): string { - if (!profile) return ""; + if (!profile) return ""; - if ("id" in profile) { - return profile.id; - } else if ("credentialId" in profile) { - return profile.credentialId; - } else if ("identifier" in profile) { - return profile.identifier; - } + if ("id" in profile) { + return profile.id; + } else if ("credentialId" in profile) { + return profile.credentialId; + } else if ("identifier" in profile) { + return profile.identifier; + } - return ""; + return ""; } export function useEmbeddedWallets(params: { - clientId?: string; - ecosystemSlug?: string; - teamId: string; - page: number; - authToken: string; + clientId?: string; + ecosystemSlug?: string; + teamId: string; + page: number; + authToken: string; }) { - const { clientId, ecosystemSlug, teamId, page, authToken } = params; - const address = useActiveAccount()?.address; - - return useQuery({ - enabled: !!address && !!(clientId || ecosystemSlug), - queryFn: fetchAccountList({ - clientId, - ecosystemSlug, - teamId, - jwt: authToken, - pageNumber: page, - }), - queryKey: embeddedWalletsKeys.embeddedWallets( - address || "", - clientId || ecosystemSlug || "", - page, - ), - }); + const { clientId, ecosystemSlug, teamId, page, authToken } = params; + const address = useActiveAccount()?.address; + + return useQuery({ + enabled: !!address && !!(clientId || ecosystemSlug), + queryFn: fetchAccountList({ + clientId, + ecosystemSlug, + teamId, + jwt: authToken, + pageNumber: page, + }), + queryKey: embeddedWalletsKeys.embeddedWallets( + address || "", + clientId || ecosystemSlug || "", + page, + ), + }); } // TODO: fetching list of all users needs to be improved export function useAllEmbeddedWallets(params: { authToken: string }) { - const { authToken } = params; - const queryClient = useQueryClient(); - const address = useActiveAccount()?.address; - - return useMutation({ - mutationFn: async ({ - clientId, - ecosystemSlug, - teamId, - }: { - clientId?: string; - ecosystemSlug?: string; - teamId: string; - }) => { - const responses: WalletUser[] = []; - let page = 1; - - while (true) { - const res = await queryClient.fetchQuery<{ - users: WalletUser[]; - }>({ - queryFn: fetchAccountList({ - clientId, - ecosystemSlug, - teamId, - jwt: authToken, - pageNumber: page, - }), - queryKey: embeddedWalletsKeys.embeddedWallets( - address || "", - clientId || ecosystemSlug || "", - page, - ), - }); - - if (res.users.length === 0) { - break; - } - - page++; - responses.push(...res.users); - } - - return responses; - }, - }); + const { authToken } = params; + const queryClient = useQueryClient(); + const address = useActiveAccount()?.address; + + return useMutation({ + mutationFn: async ({ + clientId, + ecosystemSlug, + teamId, + }: { + clientId?: string; + ecosystemSlug?: string; + teamId: string; + }) => { + const responses: WalletUser[] = []; + let page = 1; + + while (true) { + const res = await queryClient.fetchQuery<{ + users: WalletUser[]; + hasMore: boolean; + }>({ + queryFn: fetchAccountList({ + clientId, + ecosystemSlug, + teamId, + jwt: authToken, + pageNumber: page, + }), + queryKey: embeddedWalletsKeys.embeddedWallets( + address || "", + clientId || ecosystemSlug || "", + page, + ), + }); + + responses.push(...res.users); + + if (!res.hasMore) { + break; + } + + page++; + } + + return responses; + }, + }); } From f9370951fe57b227d880a87cab0bdc5db129b547 Mon Sep 17 00:00:00 2001 From: 0xFirekeeper <0xFirekeeper@gmail.com> Date: Fri, 5 Sep 2025 05:10:43 +0700 Subject: [PATCH 6/6] fmt --- .../src/@/hooks/useEmbeddedWallets.ts | 346 +++++++++--------- 1 file changed, 173 insertions(+), 173 deletions(-) diff --git a/apps/dashboard/src/@/hooks/useEmbeddedWallets.ts b/apps/dashboard/src/@/hooks/useEmbeddedWallets.ts index 1e529c05a72..1ca70f938a4 100644 --- a/apps/dashboard/src/@/hooks/useEmbeddedWallets.ts +++ b/apps/dashboard/src/@/hooks/useEmbeddedWallets.ts @@ -1,7 +1,7 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; import type { - ListUserWalletsData, - ListUserWalletsResponses, + ListUserWalletsData, + ListUserWalletsResponses, } from "@thirdweb-dev/api"; import { configure, listUserWallets } from "@thirdweb-dev/api"; import { useActiveAccount } from "thirdweb/react"; @@ -11,9 +11,9 @@ import { embeddedWalletsKeys } from "../query-keys/cache-keys"; // Configure the API client to use the correct base URL configure({ - override: { - baseUrl: THIRDWEB_API_HOST, - }, + override: { + baseUrl: THIRDWEB_API_HOST, + }, }); // Extract types from the generated API @@ -21,192 +21,192 @@ type APIWallet = ListUserWalletsResponses[200]["result"]["wallets"][0]; type APIProfile = APIWallet["profiles"][0]; const fetchAccountList = ({ - jwt, - clientId, - ecosystemSlug, - teamId, - pageNumber, + jwt, + clientId, + ecosystemSlug, + teamId, + pageNumber, }: { - jwt: string; - clientId?: string; - ecosystemSlug?: string; - teamId: string; - pageNumber: number; + jwt: string; + clientId?: string; + ecosystemSlug?: string; + teamId: string; + pageNumber: number; }) => { - return async () => { - try { - // Prepare query parameters for the new API - const queryParams: ListUserWalletsData["query"] = { - page: pageNumber, - limit: 50, // Keep the same page size - }; - - // Use the generated API function with Bearer authentication - const response = await listUserWallets({ - query: queryParams, - headers: { - Authorization: `Bearer ${jwt}`, - "Content-Type": "application/json", - "x-thirdweb-team-id": teamId, - ...(clientId && { "x-client-id": clientId }), - ...(ecosystemSlug && { - "x-ecosystem-id": `ecosystem.${ecosystemSlug}`, - }), - }, - }); - - // Handle response - if (response.error || !response.data) { - const errorMessage = - typeof response.error === "string" - ? response.error - : "No data returned"; - throw new Error(errorMessage); - } - - // Transform the response to match the expected format - return { - users: response.data.result.wallets.map(transformToWalletUser), - hasMore: response.data.result.pagination.hasMore ?? false, - }; - } catch (error) { - console.error("Failed to fetch wallets:", error); - throw error; - } - }; + return async () => { + try { + // Prepare query parameters for the new API + const queryParams: ListUserWalletsData["query"] = { + page: pageNumber, + limit: 50, // Keep the same page size + }; + + // Use the generated API function with Bearer authentication + const response = await listUserWallets({ + query: queryParams, + headers: { + Authorization: `Bearer ${jwt}`, + "Content-Type": "application/json", + "x-thirdweb-team-id": teamId, + ...(clientId && { "x-client-id": clientId }), + ...(ecosystemSlug && { + "x-ecosystem-id": `ecosystem.${ecosystemSlug}`, + }), + }, + }); + + // Handle response + if (response.error || !response.data) { + const errorMessage = + typeof response.error === "string" + ? response.error + : "No data returned"; + throw new Error(errorMessage); + } + + // Transform the response to match the expected format + return { + users: response.data.result.wallets.map(transformToWalletUser), + hasMore: response.data.result.pagination.hasMore ?? false, + }; + } catch (error) { + console.error("Failed to fetch wallets:", error); + throw error; + } + }; }; // Transform API response to match existing WalletUser format function transformToWalletUser(apiWallet: APIWallet): WalletUser { - return { - id: getProfileId(apiWallet.profiles[0]) || "", - linkedAccounts: apiWallet.profiles.map((profile) => { - // Create details object based on the profile data - let details: - | { email: string; [key: string]: string } - | { phone: string; [key: string]: string } - | { address: string; [key: string]: string } - | { id: string; [key: string]: string }; - - const profileId = getProfileId(profile); - - if ("email" in profile && profile.email) { - details = { email: profile.email, id: profileId }; - } else if ("phone" in profile && profile.phone) { - details = { phone: profile.phone, id: profileId }; - } else if ("walletAddress" in profile && profile.walletAddress) { - details = { address: profile.walletAddress, id: profileId }; - } else { - details = { id: profileId }; - } - - return { - type: profile.type, - details, - }; - }), - wallets: apiWallet.address - ? [ - { - address: apiWallet.address, - createdAt: apiWallet.createdAt || new Date().toISOString(), - type: "enclave" as const, - }, - ] - : [], - }; + return { + id: getProfileId(apiWallet.profiles[0]) || "", + linkedAccounts: apiWallet.profiles.map((profile) => { + // Create details object based on the profile data + let details: + | { email: string; [key: string]: string } + | { phone: string; [key: string]: string } + | { address: string; [key: string]: string } + | { id: string; [key: string]: string }; + + const profileId = getProfileId(profile); + + if ("email" in profile && profile.email) { + details = { email: profile.email, id: profileId }; + } else if ("phone" in profile && profile.phone) { + details = { phone: profile.phone, id: profileId }; + } else if ("walletAddress" in profile && profile.walletAddress) { + details = { address: profile.walletAddress, id: profileId }; + } else { + details = { id: profileId }; + } + + return { + type: profile.type, + details, + }; + }), + wallets: apiWallet.address + ? [ + { + address: apiWallet.address, + createdAt: apiWallet.createdAt || new Date().toISOString(), + type: "enclave" as const, + }, + ] + : [], + }; } // Helper function to safely get ID from any profile type function getProfileId(profile: APIProfile | undefined): string { - if (!profile) return ""; + if (!profile) return ""; - if ("id" in profile) { - return profile.id; - } else if ("credentialId" in profile) { - return profile.credentialId; - } else if ("identifier" in profile) { - return profile.identifier; - } + if ("id" in profile) { + return profile.id; + } else if ("credentialId" in profile) { + return profile.credentialId; + } else if ("identifier" in profile) { + return profile.identifier; + } - return ""; + return ""; } export function useEmbeddedWallets(params: { - clientId?: string; - ecosystemSlug?: string; - teamId: string; - page: number; - authToken: string; + clientId?: string; + ecosystemSlug?: string; + teamId: string; + page: number; + authToken: string; }) { - const { clientId, ecosystemSlug, teamId, page, authToken } = params; - const address = useActiveAccount()?.address; - - return useQuery({ - enabled: !!address && !!(clientId || ecosystemSlug), - queryFn: fetchAccountList({ - clientId, - ecosystemSlug, - teamId, - jwt: authToken, - pageNumber: page, - }), - queryKey: embeddedWalletsKeys.embeddedWallets( - address || "", - clientId || ecosystemSlug || "", - page, - ), - }); + const { clientId, ecosystemSlug, teamId, page, authToken } = params; + const address = useActiveAccount()?.address; + + return useQuery({ + enabled: !!address && !!(clientId || ecosystemSlug), + queryFn: fetchAccountList({ + clientId, + ecosystemSlug, + teamId, + jwt: authToken, + pageNumber: page, + }), + queryKey: embeddedWalletsKeys.embeddedWallets( + address || "", + clientId || ecosystemSlug || "", + page, + ), + }); } // TODO: fetching list of all users needs to be improved export function useAllEmbeddedWallets(params: { authToken: string }) { - const { authToken } = params; - const queryClient = useQueryClient(); - const address = useActiveAccount()?.address; - - return useMutation({ - mutationFn: async ({ - clientId, - ecosystemSlug, - teamId, - }: { - clientId?: string; - ecosystemSlug?: string; - teamId: string; - }) => { - const responses: WalletUser[] = []; - let page = 1; - - while (true) { - const res = await queryClient.fetchQuery<{ - users: WalletUser[]; - hasMore: boolean; - }>({ - queryFn: fetchAccountList({ - clientId, - ecosystemSlug, - teamId, - jwt: authToken, - pageNumber: page, - }), - queryKey: embeddedWalletsKeys.embeddedWallets( - address || "", - clientId || ecosystemSlug || "", - page, - ), - }); - - responses.push(...res.users); - - if (!res.hasMore) { - break; - } - - page++; - } - - return responses; - }, - }); + const { authToken } = params; + const queryClient = useQueryClient(); + const address = useActiveAccount()?.address; + + return useMutation({ + mutationFn: async ({ + clientId, + ecosystemSlug, + teamId, + }: { + clientId?: string; + ecosystemSlug?: string; + teamId: string; + }) => { + const responses: WalletUser[] = []; + let page = 1; + + while (true) { + const res = await queryClient.fetchQuery<{ + users: WalletUser[]; + hasMore: boolean; + }>({ + queryFn: fetchAccountList({ + clientId, + ecosystemSlug, + teamId, + jwt: authToken, + pageNumber: page, + }), + queryKey: embeddedWalletsKeys.embeddedWallets( + address || "", + clientId || ecosystemSlug || "", + page, + ), + }); + + responses.push(...res.users); + + if (!res.hasMore) { + break; + } + + page++; + } + + return responses; + }, + }); }