### Install Thirdweb .NET SDK via NuGet Source: https://github.com/thirdweb-dev/dotnet/blob/main/README.md Installs the Thirdweb .NET SDK package using the .NET CLI. This is the recommended way to add the SDK to your project, ensuring you have the latest stable version and its dependencies managed automatically. ```bash dotnet add package Thirdweb ``` -------------------------------- ### Token Sale Setup Source: https://github.com/thirdweb-dev/dotnet/blob/main/llms.txt Configuration for setting up a token for a sale. ```APIDOC ## Token Sale Setup ### Description Endpoint to configure a token for an upcoming sale, likely involving setting sale parameters and availability. ### Method POST ### Endpoint `/api/tokens/{tokenId}/sale` ### Parameters #### Path Parameters - **tokenId** (string) - Required - The ID of the token to configure for sale. #### Query Parameters None #### Request Body - **Sale** (object) - Optional - Setup this token for a sale. Specific sale parameters would be detailed here. ### Request Example ```json { "Sale": { "startDate": "2023-10-27T10:00:00Z", "endDate": "2023-10-27T12:00:00Z", "price": "0.1" } } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example ```json { "status": "Sale configuration updated" } ``` ``` -------------------------------- ### C# Wallet Operations: Balance, Transfer, and Sign Source: https://context7.com/thirdweb-dev/dotnet/llms.txt Demonstrates how to perform common wallet operations using the Thirdweb .NET SDK, including getting token balances (native and ERC20), transferring tokens, retrieving transaction counts, signing messages, and switching networks. Requires Thirdweb SDK installation and initialization with a client ID. ```csharp using Thirdweb; using System.Numerics; var client = ThirdwebClient.Create(clientId: "your_client_id"); var wallet = await InAppWallet.Create(client, email: "user@example.com"); await wallet.LoginWithOtp("123456"); var userAddress = await wallet.GetAddress(); // Get native token balance (ETH, MATIC, etc.) var nativeBalance = await wallet.GetBalance(chainId: 137); // Polygon Console.WriteLine($"Native balance: {nativeBalance.ToString().ToEth()} MATIC"); // Get ERC20 token balance var usdcBalance = await wallet.GetBalance( chainId: 137, erc20ContractAddress: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174" ); Console.WriteLine($"USDC balance: {usdcBalance / BigInteger.Pow(10, 6)} USDC"); // Get transaction count (nonce) var txCount = await wallet.GetTransactionCount( chainId: 137, blocktag: "latest" ); Console.WriteLine($"Transaction count: {txCount}"); // Transfer native tokens var transferReceipt = await wallet.Transfer( chainId: 137, toAddress: "0xRecipientAddress", weiAmount: BigInteger.Parse("1000000000000000000") // 1 MATIC ); Console.WriteLine($"Transfer successful: {transferReceipt.TransactionHash}"); Console.WriteLine($"Gas used: {transferReceipt.GasUsed}"); // Transfer with custom gas settings var customTransfer = await ThirdwebTransaction.Create( wallet: wallet, txInput: new ThirdwebTransactionInput( chainId: 137, to: "0xRecipientAddress", value: BigInteger.Parse("500000000000000000") // 0.5 MATIC ) ); customTransfer .SetGasLimit(BigInteger.Parse("21000")) .SetMaxFeePerGas(BigInteger.Parse("50000000000")); var customReceipt = await ThirdwebTransaction.SendAndWaitForTransactionReceipt(customTransfer); Console.WriteLine($"Custom transfer: {customReceipt.TransactionHash}"); // Sign message var message = "Sign this message to authenticate"; var signature = await wallet.PersonalSign(message); Console.WriteLine($"Signature: {signature}"); // Verify signature (if supported by wallet type) if (wallet is SmartWallet smartWallet) { var isValid = await smartWallet.IsValidSignature(message, signature); Console.WriteLine($"Signature valid: {isValid}"); } // Switch network await wallet.SwitchNetwork(chainId: 1); // Switch to Ethereum mainnet Console.WriteLine("Network switched to Ethereum"); ``` -------------------------------- ### Initiate Authentication Source: https://github.com/thirdweb-dev/dotnet/blob/main/llms.txt Starts any authentication flow, supporting SMS, email, Passkey, and SIWE. Requires appropriate headers for authentication. ```APIDOC ## POST /v1/auth/initiate ### Description Initiates an authentication flow. This endpoint supports multiple authentication methods including SMS, email, Passkey, and Sign-In with Ethereum (SIWE). ### Method POST ### Endpoint /v1/auth/initiate ### Parameters #### Request Body - **body** (Thirdweb.Api.Body) - Required - The request body containing authentication details. ### Request Example ```json { "method": "sms", "phoneNumber": "+1234567890" } ``` ### Response #### Success Response (200) - **challengeData** (object) - Data required to complete the authentication challenge. #### Response Example ```json { "challengeData": { "challenge": "...", "signature": "..." } } ``` ### Headers - **x-client-id** (string) - Required for frontend usage. - **x-secret-key** (string) - Required for backend usage. ``` -------------------------------- ### GET /wallets/solana Source: https://github.com/thirdweb-dev/dotnet/blob/main/llms.txt List all Solana wallets created for your project. Supports pagination with page and limit parameters. ```APIDOC ## GET /wallets/solana ### Description List all Solana wallets created for your project. Supports pagination with page and limit parameters. ### Method GET ### Endpoint /wallets/solana ### Parameters #### Query Parameters - **page** (integer) - Optional - Page number for paginated results. Starts at 1. - **limit** (integer) - Optional - Maximum number of wallets to return per page. ### Request Example ```json { "page": 1, "limit": 20 } ``` ### Response #### Success Response (200) - **wallets** (array) - An array of Solana wallet objects. - **pageInfo** (object) - Pagination metadata. #### Response Example ```json { "wallets": [ { "address": "0xSolanaWalletAddress1", "label": "Wallet 1" }, { "address": "0xSolanaWalletAddress2", "label": "Wallet 2" } ], "pageInfo": { "nextCursor": "...", "hasNextPage": true } } ``` ### Error Handling - **ApiException**: A server-side error occurred. ``` -------------------------------- ### Create Smart Wallet with Gas Sponsorship - C# Source: https://context7.com/thirdweb-dev/dotnet/llms.txt This snippet demonstrates how to create a Smart Wallet (EIP-4337) using the Thirdweb .NET SDK. It includes examples for creating a personal wallet as a signer, enabling gas sponsorship, and creating a Smart Wallet with a custom factory and entry point. It also shows how to check deployment status, force deployment, and set up session keys for delegated permissions. ```csharp using Thirdweb; using System.Numerics; var client = ThirdwebClient.Create(secretKey: "your_secret_key"); // Create a personal wallet as signer var personalWallet = await InAppWallet.Create( client: client, email: "user@example.com" ); await personalWallet.LoginWithOtp(otp: "123456"); // Create Smart Wallet with gas sponsorship var smartWallet = await SmartWallet.Create( personalWallet: personalWallet, chainId: 137, // Polygon gasless: true // Enable gas sponsorship ); var smartWalletAddress = await smartWallet.GetAddress(); Console.WriteLine($"Smart Wallet address: {smartWalletAddress}"); // Create Smart Wallet with custom factory and entry point var customSmartWallet = await SmartWallet.Create( personalWallet: personalWallet, chainId: 1, // Ethereum mainnet gasless: true, factoryAddress: "0x1234...", // Custom factory entryPoint: Constants.ENTRYPOINT_ADDRESS_V07 // EIP-4337 v0.7 ); // Check if smart wallet is deployed var isDeployed = await smartWallet.IsDeployed(); Console.WriteLine($"Smart Wallet deployed: {isDeployed}"); // Force deployment if needed if (!isDeployed) { await smartWallet.ForceDeploy(); Console.WriteLine("Smart Wallet deployed successfully"); } // Create session key for delegated permissions var sessionReceipt = await smartWallet.CreateSessionKey( signerAddress: "0x789...", approvedTargets: new List { "0xContractAddress..." }, nativeTokenLimitPerTransactionInWei: "1000000000000000000", // 1 token permissionStartTimestamp: "0", permissionEndTimestamp: Utils.GetUnixTimeStampIn10Years().ToString() ); Console.WriteLine($"Session key created: {sessionReceipt.TransactionHash}"); // Get all active signers var signers = await smartWallet.GetAllActiveSigners(); foreach (var signer in signers) { Console.WriteLine($"Signer: {signer.Signer}, Approved: {signer.ApprovedTargets.Count} targets"); } ``` -------------------------------- ### Discover Payable Services (C#) Source: https://github.com/thirdweb-dev/dotnet/blob/main/llms.txt Lists payable x402 compatible services and HTTP endpoints that can be paid for using the fetchWithPayment tool. It helps in browsing services, APIs, and endpoints. Each item includes a resource URL callable with fetchWithPayment. Price is in base units of the asset, with examples provided for interpretation. ```csharp public async Task> ListPayableServicesAsync( double? minAmount = null, double? maxAmount = null, string? assetContractAddress = null, SortBy2? sortBy = null, SortOrder5? sortOrder = null, CancellationToken cancellationToken = default ) { // Implementation details... return new List(); } ``` -------------------------------- ### Create Token Source: https://github.com/thirdweb-dev/dotnet/blob/main/llms.txt Create a new ERC20 token with the provided metadata and starting price. The token is immediately available for purchase using thirdweb Payments. ```APIDOC ## POST /create-token ### Description 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. ### Method POST ### Endpoint /create-token ### Parameters #### Request Body - **body** (Body19) - Required - Metadata and starting price for the token. ### Request Example ```json { "body": { "name": "My Awesome Token", "symbol": "MAT", "price": "1000000" } } ``` ### Response #### Success Response (200) - **predicted_address** (string) - The predicted token address. #### Response Example ```json { "predicted_address": "0x1234567890abcdef1234567890abcdef12345678" } ``` ### Error Handling - **ApiException** - A server side error occurred. ``` -------------------------------- ### Perform ERC721 NFT Operations with Thirdweb .NET SDK Source: https://context7.com/thirdweb-dev/dotnet/llms.txt This C# code demonstrates how to interact with ERC721 NFT contracts using the Thirdweb .NET SDK. It covers essential operations such as initializing the SDK, creating/getting NFT contracts, retrieving collection details, managing NFTs (getting individual NFTs, owned NFTs, balance), and performing transactions like transfer, approve, setApprovalForAll, and mint. ```csharp using Thirdweb; using System.Numerics; using Newtonsoft.Json; var client = ThirdwebClient.Create(secretKey: "your_secret_key"); var wallet = await InAppWallet.Create(client, email: "user@example.com"); await wallet.LoginWithOtp("123456"); // Create NFT contract var nftContract = await ThirdwebContract.Create( client: client, address: "0xNFTContractAddress", chain: 1 ); // Get collection info var collectionName = await nftContract.ERC721_Name(); var collectionSymbol = await nftContract.ERC721_Symbol(); Console.WriteLine($"Collection: {collectionName} ({collectionSymbol})"); // Get total supply var totalSupply = await nftContract.ERC721_TotalSupply(); Console.WriteLine($"Total minted: {totalSupply}"); // Get NFT metadata var nft = await nftContract.ERC721_GetNFT(tokenId: 0); Console.WriteLine($"NFT #{nft.Metadata.Id}"); Console.WriteLine($"Name: {nft.Metadata.Name}"); Console.WriteLine($"Description: {nft.Metadata.Description}"); Console.WriteLine($"Image: {nft.Metadata.Image}"); Console.WriteLine($"Owner: {nft.Owner}"); // Get all owned NFTs var userAddress = await wallet.GetAddress(); var ownedNFTs = await nftContract.ERC721_GetOwned(walletAddress: userAddress); Console.WriteLine($"User owns {ownedNFTs.Count} NFTs"); foreach (var ownedNft in ownedNFTs) { Console.WriteLine($" - Token #{ownedNft.Metadata.Id}: {ownedNft.Metadata.Name}"); } // Check balance var nftBalance = await nftContract.ERC721_BalanceOf(userAddress); Console.WriteLine($"NFT balance: {nftBalance}"); // Transfer NFT var transferReceipt = await nftContract.ERC721_Transfer( wallet: wallet, to: "0xRecipientAddress", tokenId: 5 ); Console.WriteLine($"NFT transferred: {transferReceipt.TransactionHash}"); // Approve NFT for transfer var approveReceipt = await nftContract.ERC721_Approve( wallet: wallet, to: "0xApprovedAddress", tokenId: 5 ); Console.WriteLine($"NFT approved: {approveReceipt.TransactionHash}"); // Set approval for all NFTs var setApprovalReceipt = await nftContract.ERC721_SetApprovalForAll( wallet: wallet, operatorAddress: "0xMarketplaceAddress", approved: true ); Console.WriteLine($"Operator approved: {setApprovalReceipt.TransactionHash}"); // Mint NFT (if contract supports it) var mintReceipt = await nftContract.ERC721_Mint( wallet: wallet, mintRequest: new NFTMintRequest { Receiver = userAddress, Metadata = new NFTMetadata { Name = "My New NFT", Description = "Created with Thirdweb SDK", Image = "ipfs://QmHash..." } } ); Console.WriteLine($"NFT minted: {mintReceipt.TransactionHash}"); ``` -------------------------------- ### Create ERC20 Token (C#) Source: https://github.com/thirdweb-dev/dotnet/blob/main/llms.txt Creates a new ERC20 token with provided metadata and starting price, making it available for purchase via thirdweb Payments. Requires project and wallet authentication. For backend usage, use 'x-secret-key' header; for frontend, use 'x-client-id' + 'Authorization: Bearer ' headers. Returns the predicted token address. ```csharp public async Task CreateTokenAsync(Body19 tokenMetadata) { // Implementation details... return new TokenDeploymentResult(); } public async Task CreateTokenAsync(Body19 tokenMetadata, CancellationToken cancellationToken) { // Implementation details... return new TokenDeploymentResult(); } ``` -------------------------------- ### GET /fetch Source: https://github.com/thirdweb-dev/dotnet/blob/main/llms.txt Fetches a resource using a specified payment method. This endpoint requires details about the 'from' address, the asset, the chain ID, and potentially other payment-related parameters. ```APIDOC ## GET /fetch ### Description Fetches a resource using a specified payment method. This endpoint requires details about the 'from' address, the asset, the chain ID, and potentially other payment-related parameters. ### Method GET ### Endpoint /fetch ### Parameters #### Query Parameters - **from** (string) - Required - A valid blockchain address. Accepts Ethereum (0x...) and Solana (base58) addresses, as well as ENS names for Ethereum. - **asset** (Uri) - Required - The URI of the asset to fetch. - **chainId** (ChainId2) - Required - Chain ID to use for the payment. Supports CAIP-2 strings (e.g., 'eip155:1', 'solana:mainnet') or legacy numeric EVM IDs. - **paymentMethod** (string) - Required - The payment method to use for fetching. - **paymentDetails** (string) - Optional - Additional details for the payment method. - **nonce** (object) - Optional - Nonce object for payment. ### Response #### Success Response (200) - **Resource data** (object or string) - The data of the fetched resource. #### Response Example ```json { "data": "..." } ``` #### Error Response (400 or 500) - **A server side error occurred.** (ApiException) - Indicates a server-side error during the fetch operation. ``` -------------------------------- ### Initialize Thirdweb SDK Client (.NET) Source: https://context7.com/thirdweb-dev/dotnet/llms.txt Creates a Thirdweb client instance, the main entry point for SDK operations. Supports initialization with secret keys (server-side), client IDs (client-side), custom RPC endpoints for specific chains, and custom timeout configurations for storage and RPC calls. ```csharp using Thirdweb; using System.Numerics; // Create client with secret key (server-side only) var client = ThirdwebClient.Create( secretKey: "your_secret_key_here" ); // Create client with client ID (client-side applications) var clientWithId = ThirdwebClient.Create( clientId: "your_client_id_here" ); // Create client with custom RPC endpoints var customRpcClient = ThirdwebClient.Create( clientId: "your_client_id", rpcOverrides: new Dictionary { { 1, "https://mainnet.infura.io/v3/YOUR-PROJECT-ID" }, { 137, "https://polygon-rpc.com" } } ); // Create client with custom timeout options var clientWithTimeout = ThirdwebClient.Create( clientId: "your_client_id", fetchTimeoutOptions: new TimeoutOptions { StorageTimeoutMs = 60000, RpcTimeoutMs = 120000 } ); Console.WriteLine($"Client initialized with ID: {client.ClientId}"); ``` -------------------------------- ### Get Solana Swap Quote Source: https://github.com/thirdweb-dev/dotnet/blob/main/llms.txt Get a quote for swapping tokens on Solana. This endpoint returns the expected output amount and swap details without executing the transaction. Swaps are only available on Solana mainnet. Backend authentication is required. ```APIDOC ## GET /v1/solana/swap/quote ### Description Get a quote for swapping tokens on Solana. This endpoint returns the expected output amount and swap details without executing the transaction. Swaps are only available on Solana mainnet. ### Method GET ### Endpoint /v1/solana/swap/quote ### Parameters #### Query Parameters - **x-secret-key** (string) - Required - Your backend secret key for authentication. - **address** (string) - Required - Solana wallet address that will execute the swap. - **tokenIn** (string) - Required - Input token mint address (the token being sold). - **tokenOut** (string) - Required - Output token mint address (the token being purchased). - **amount** (string) - Required - Amount of input token to swap, expressed in the smallest unit (e.g., lamports for SOL). ### Request Example ```json { "address": "", "tokenIn": "", "tokenOut": "", "amount": "1000000" } ``` ### Response #### Success Response (200) - **quote** (object) - Swap quote details. - **expectedOutputAmount** (string) - The expected amount of output tokens. - **swapDetails** (object) - Details of the swap. #### Response Example ```json { "quote": { "expectedOutputAmount": "5000000", "swapDetails": { ... } } } ``` ### Error Handling - **T:Thirdweb.Api.ApiException**: A server side error occurred. ``` -------------------------------- ### GetUnixTimeStampNow Source: https://github.com/thirdweb-dev/dotnet/blob/main/llms.txt Gets the current Unix timestamp. ```APIDOC ## GET /utils/timestamp/now ### Description Gets the current Unix timestamp. ### Method GET ### Endpoint `/utils/timestamp/now` ### Response #### Success Response (200) - **timestamp** (long) - The current Unix timestamp. #### Response Example ```json { "timestamp": 1678886400 } ``` ``` -------------------------------- ### GetUnixTimeStampIn10Years Source: https://github.com/thirdweb-dev/dotnet/blob/main/llms.txt Gets the Unix timestamp for 10 years from now. ```APIDOC ## GET /utils/timestamp/in-10-years ### Description Gets the Unix timestamp for 10 years from now. ### Method GET ### Endpoint `/utils/timestamp/in-10-years` ### Response #### Success Response (200) - **timestamp** (long) - The Unix timestamp for 10 years from now. #### Response Example ```json { "timestamp": 2005356800 } ``` ``` -------------------------------- ### Interact with Smart Contracts - C# Source: https://context7.com/thirdweb-dev/dotnet/llms.txt This snippet shows how to interact with smart contracts using the Thirdweb .NET SDK. It covers creating contract instances with automatic ABI fetching or by providing a custom ABI. It demonstrates reading data from contracts (view/pure functions) and writing data (state-changing functions), including preparing transactions, estimating gas costs, and sending transactions. ```csharp using Thirdweb; using System.Numerics; var client = ThirdwebClient.Create(clientId: "your_client_id"); // Create contract with automatic ABI fetching var contract = await ThirdwebContract.Create( client: client, address: "0xContractAddress", chain: 1 // Ethereum mainnet ); // Create contract with custom ABI var customContract = await ThirdwebContract.Create( client: client, address: "0xContractAddress", chain: 137, abi: "[{\"inputs\":[],\"name\":\"getValue\",\"outputs\":[{\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]" ); // Read from contract (view/pure functions) var tokenName = await ThirdwebContract.Read( contract: contract, method: "name" ); Console.WriteLine($"Token name: {tokenName}"); var balance = await ThirdwebContract.Read( contract: contract, method: "balanceOf", parameters: "0xUserAddress" ); Console.WriteLine($"Balance: {balance}"); // Write to contract (state-changing functions) var wallet = await InAppWallet.Create(client, email: "user@example.com"); await wallet.LoginWithOtp("123456"); var receipt = await ThirdwebContract.Write( wallet: wallet, contract: contract, method: "transfer", weiValue: 0, parameters: new object[] { "0xRecipientAddress", BigInteger.Parse("1000000000000000000") } ); Console.WriteLine($"Transaction hash: {receipt.TransactionHash}"); Console.WriteLine($"Status: {(receipt.Status == 1 ? "Success" : "Failed")}"); // Prepare transaction without sending var preparedTx = await ThirdwebContract.Prepare( wallet: wallet, contract: contract, method: "approve", weiValue: 0, parameters: new object[] { "0xSpenderAddress", BigInteger.Parse("1000000") } ); // Estimate gas costs var gasCosts = await ThirdwebTransaction.EstimateGasCosts(preparedTx); Console.WriteLine($"Estimated gas cost: {gasCosts.Ether} ETH"); // Send prepared transaction var txHash = await ThirdwebTransaction.Send(preparedTx); Console.WriteLine($"Transaction sent: {txHash}"); ``` -------------------------------- ### ERC20 Name Source: https://github.com/thirdweb-dev/dotnet/blob/main/llms.txt Gets the name of an ERC20 token. ```APIDOC ## POST /erc20/name ### Description Gets the name of an ERC20 token. ### Method POST ### Endpoint /erc20/name ### Parameters #### Request Body - **contract** (ThirdwebContract) - Required - The contract to interact with. ### Request Example ```json { "contract": {"__type": "ThirdwebContract"} } ``` ### Response #### Success Response (200) - **name** (string) - The name of the token. #### Response Example ```json { "name": "Ethereum" } ``` ### Exceptions - **ArgumentNullException**: Thrown when the contract is null. ``` -------------------------------- ### Get Transaction Nonce Source: https://github.com/thirdweb-dev/dotnet/blob/main/llms.txt Retrieves the nonce for a given transaction. ```APIDOC ## POST /transactions/nonce ### Description Gets the transaction nonce, which is required for sending transactions from an account. ### Method POST ### Endpoint /transactions/nonce ### Parameters #### Request Body - **transaction** (ThirdwebTransaction) - Required - The transaction object for which to get the nonce. ### Request Example ```json { "transaction": { "from": "0x...", "to": "0x...", "value": "1000000000000000000" } } ``` ### Response #### Success Response (200) - **nonce** (string) - The transaction nonce. #### Response Example ```json { "nonce": "15" } ``` ``` -------------------------------- ### Deploy Smart Contracts with Thirdweb .NET SDK Source: https://context7.com/thirdweb-dev/dotnet/llms.txt Deploys smart contracts to a specified blockchain using a server wallet. Supports constructor parameters for contract initialization and deterministic deployment via salt values. Requires ThirdwebClient initialization and contract bytecode/ABI. ```csharp using Thirdweb; using System.Numerics; using System.Collections.Generic; var client = ThirdwebClient.Create(secretKey: "your_secret_key"); // Define contract bytecode and ABI var bytecode = "0x608060405234801561001057600080fd5b50..."; // Full contract bytecode var abi = @"[ { "inputs": [ {"name": "_name", "type": "string"}, {"name": "_symbol", "type": "string"} ], "stateMutability": "nonpayable", "type": "constructor" } ]"; // Deploy contract with constructor parameters var contractAddress = await ThirdwebContract.Deploy( client: client, chainId: 80001, // Mumbai testnet serverWalletAddress: "0xYourServerWallet", bytecode: bytecode, abi: abi, constructorParams: new Dictionary { { "_name", "MyToken" }, { "_symbol", "MTK" } } ); Console.WriteLine($"Contract deployed at: {contractAddress}"); // Deploy with deterministic address using salt var saltedAddress = await ThirdwebContract.Deploy( client: client, chainId: 137, serverWalletAddress: "0xYourServerWallet", bytecode: bytecode, abi: abi, constructorParams: new Dictionary { { "_name", "MyToken" }, { "_symbol", "MTK" } }, salt: "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef" ); Console.WriteLine($"Contract deployed at deterministic address: {saltedAddress}"); // Interact with deployed contract var deployedContract = await ThirdwebContract.Create( client: client, address: contractAddress, chain: 80001 ); var name = await ThirdwebContract.Read(deployedContract, "name"); Console.WriteLine($"Deployed contract name: {name}"); ``` -------------------------------- ### ERC20 Decimals Source: https://github.com/thirdweb-dev/dotnet/blob/main/llms.txt Gets the number of decimals used by an ERC20 token. ```APIDOC ## POST /erc20/decimals ### Description Gets the number of decimals used by an ERC20 token. ### Method POST ### Endpoint /erc20/decimals ### Parameters #### Request Body - **contract** (ThirdwebContract) - Required - The contract to interact with. ### Request Example ```json { "contract": {"__type": "ThirdwebContract"} } ``` ### Response #### Success Response (200) - **decimals** (int) - The number of decimals. #### Response Example ```json { "decimals": 18 } ``` ### Exceptions - **ArgumentNullException**: Thrown when the contract is null. ``` -------------------------------- ### Get Payment History Source: https://github.com/thirdweb-dev/dotnet/blob/main/llms.txt Retrieves the payment history for a specific payment link. ```APIDOC ## GET /payments/{paymentId}/history ### Description Gets the payment history for a specific payment link. ### Method GET ### Endpoint /payments/{paymentId}/history ### Parameters #### Path Parameters - **paymentId** (string) - Required - The ID of the payment link to get history for. ### Response #### Success Response (200) - **history** (array) - An array of payment history records. #### Response Example ```json { "example": { "history": [ { "transactionId": "0xabc...", "amount": "100", "timestamp": "2023-01-01T10:00:00Z" } ] } } ``` #### Error Response - **T:Thirdweb.Api.ApiException** - A server-side error occurred. ``` -------------------------------- ### Create and Authenticate In-App Wallets (.NET) Source: https://context7.com/thirdweb-dev/dotnet/llms.txt Facilitates the creation of In-App Wallets for user authentication, supporting email OTP, phone OTP, social logins (Google, Facebook), SIWE, and guest access. Provides methods to log in users via OTP, guest credentials, or OAuth flows, and to check the wallet's connection status. ```csharp using Thirdweb; var client = ThirdwebClient.Create(clientId: "your_client_id"); // Email OTP authentication var emailWallet = await InAppWallet.Create( client: client, email: "user@example.com" ); var emailAddress = await emailWallet.LoginWithOtp( otp: "123456" // User enters OTP from email ); Console.WriteLine($"Email wallet address: {emailAddress}"); // Phone OTP authentication var phoneWallet = await InAppWallet.Create( client: client, phoneNumber: "+1234567890" ); var phoneAddress = await phoneWallet.LoginWithOtp( otp: "654321" ); Console.WriteLine($"Phone wallet address: {phoneAddress}"); // Guest authentication (no credentials required) var guestWallet = await InAppWallet.Create( client: client, authProvider: AuthProvider.Guest ); var guestAddress = await guestWallet.LoginWithGuest(); Console.WriteLine($"Guest wallet address: {guestAddress}"); // Social OAuth (Google example) var googleWallet = await InAppWallet.Create( client: client, authProvider: AuthProvider.Google ); var googleAddress = await googleWallet.LoginWithOauth( isMobile: false, browserOpenAction: (url) => { // Open browser to OAuth URL System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo { FileName = url, UseShellExecute = true }); }, mobileRedirectScheme: "myapp://", browser: new InAppWalletBrowser() ); Console.WriteLine($"Google wallet address: {googleAddress}"); // Check connection status var isConnected = await emailWallet.IsConnected(); Console.WriteLine($"Wallet connected: {isConnected}"); ``` -------------------------------- ### Get Ecosystem Wallet User Details Source: https://github.com/thirdweb-dev/dotnet/blob/main/llms.txt Retrieves user details from the enclave wallet. ```APIDOC ## GET /ecosystem-wallet/userDetails ### Description Gets the user details from the enclave wallet. For auth provider specific details use GetUserAuthDetails. ### Method GET ### Endpoint /ecosystem-wallet/userDetails ### Parameters *Note: This endpoint assumes an authenticated EcosystemWallet instance is available in the current context or session.* ### Request Example ```json {} ``` ### Response #### Success Response (200) - **userDetails** (object) - The user details. #### Response Example ```json { "userDetails": { "userId": "...", "email": "user@example.com" } } ``` ``` -------------------------------- ### Product Creation API Source: https://github.com/thirdweb-dev/dotnet/blob/main/llms.txt Allows creation of products that can be purchased via hosted UI, direct transaction, or embedded widgets. Includes details such as name, description, image URL, token for purchase, recipient, and purchase data. ```APIDOC ## POST /api/products ### Description Creates a new product that can be purchased. ### Method POST ### Endpoint /api/products ### Parameters #### Request Body - **name** (string) - Required - The name of the product - **description** (string) - Optional - The description of the product - **imageUrl** (string) - Optional - The URL of the product image - **token** (string) - Required - The token to purchase - **recipient** (string) - Required - The wallet address or ENS name that will receive the payment for the product - **purchaseData** (string) - Optional - App specific purchase data for this payment ### Request Example ```json { "name": "Example Product", "description": "A sample product for demonstration.", "imageUrl": "https://example.com/image.jpg", "token": "0xYourTokenAddress", "recipient": "0xRecipientAddress", "purchaseData": "0x1234567890abcdef" } ``` ### Response #### Success Response (201) - **productId** (string) - The unique identifier of the created product. - **hostedUIUrl** (string) - A URL to the hosted UI for purchasing the product. #### Response Example ```json { "productId": "prod_12345abcde", "hostedUIUrl": "https://thirdweb.com/purchase/prod_12345abcde" } ``` ``` -------------------------------- ### Get Ecosystem Wallet User Authentication Details Source: https://github.com/thirdweb-dev/dotnet/blob/main/llms.txt Retrieves authentication-specific details for the user from the enclave wallet. ```APIDOC ## GET /ecosystem-wallet/userAuthDetails ### Description Gets the user authentication details from the enclave wallet. This provides provider-specific information. ### Method GET ### Endpoint /ecosystem-wallet/userAuthDetails ### Parameters *Note: This endpoint assumes an authenticated EcosystemWallet instance is available in the current context or session.* ### Request Example ```json {} ``` ### Response #### Success Response (200) - **userAuthDetails** (object) - The user authentication details. #### Response Example ```json { "userAuthDetails": { "provider": "EMAIL_OTP", "authDetails": {...} } } ``` ``` -------------------------------- ### List Payable Services Source: https://github.com/thirdweb-dev/dotnet/blob/main/llms.txt Discover payable x402 compatible services and HTTP endpoints that can be paid for using the fetchWithPayment tool. Use this tool to browse services, APIs and endpoints to find what you need for your tasks. Each item has a resource url that you can call with the fetchWithPayment tool. ```APIDOC ## GET /listPayableServices ### Description Discover payable x402 compatible services and HTTP endpoints that can be paid for using the fetchWithPayment tool. Use this tool to browse services, APIs and endpoints to find what you need for your tasks. Each item has a resource url that you can call with the fetchWithPayment tool. Price is in the base units of the asset. For example, if the price is 1000000 and the asset is USDC (which is the default and has 6 decimals), the price is 1 USDC. Examples: if network is eip155:8453, asset is 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913, max amount required is 10000, resource is https://api.example.com/paid-api, then you should interpret that as "the api.example.com/paid-api service costs 0.01 USDC per call". ### Method GET ### Endpoint /listPayableServices ### Parameters #### Query Parameters - **min_amount** (Nullable) - Optional - Minimum amount for filtering services. - **max_amount** (Nullable) - Optional - Maximum amount for filtering services. - **network** (string) - Optional - Network to filter services by. - **sort_by** (Nullable) - Optional - Field to sort the results by. - **sort_order** (Nullable) - Optional - Order to sort the results in. ### Response #### Success Response (200) - **resources** (List) - List of discovered x402 resources #### Response Example ```json { "resources": [ { "name": "Example Service", "description": "An example payable service.", "url": "https://api.example.com/paid-api", "price": 10000, "currency": "0x USDC" } ] } ``` ### Error Handling - **ApiException** - A server side error occurred. ``` -------------------------------- ### Get Active Claim Condition (ERC721) Source: https://github.com/thirdweb-dev/dotnet/blob/main/llms.txt Retrieves the details of the active claim condition for an ERC721 drop. ```APIDOC ## GET /contracts/{contractAddress}/drop/claim-conditions/active ### Description Get the details of the active claim condition for the ERC721 drop. ### Method GET ### Endpoint `/contracts/{contractAddress}/drop/claim-conditions/active` ### Parameters #### Path Parameters - **contractAddress** (string) - Required - The address of the contract. ### Request Example (No request body for GET request) ### Response #### Success Response (200) - **Drop_ClaimCondition** (object) - Contains the active claim condition details. #### Response Example ```json { "maxClaimable": "100", "supplyClaimed": "10", "quantityLimitPerTransaction": "5", "pricePerToken": "0.1", "snapshotTime": "2024-01-01T00:00:00Z", "merkleRoot": "0x...", "allowAllClaimers": true } ``` ### Exceptions - **System.ArgumentNullException**: Thrown when the contract is null. ``` -------------------------------- ### Get Claim Condition Details Source: https://github.com/thirdweb-dev/dotnet/blob/main/llms.txt Retrieves the details for a specific claim condition ID associated with a contract. ```APIDOC ## GET /contracts/{contractAddress}/drop/claim-conditions/{claimConditionId} ### Description Get the claim condition details for a specific claim condition ID. ### Method GET ### Endpoint `/contracts/{contractAddress}/drop/claim-conditions/{claimConditionId}` ### Parameters #### Path Parameters - **contractAddress** (string) - Required - The address of the contract. - **claimConditionId** (System.Numerics.BigInteger) - Required - The ID of the claim condition. ### Request Example (No request body for GET request) ### Response #### Success Response (200) - **Drop_ClaimCondition** (object) - Contains the claim condition details. #### Response Example ```json { "maxClaimable": "100", "supplyClaimed": "10", "quantityLimitPerTransaction": "5", "pricePerToken": "0.1", "snapshotTime": "2024-01-01T00:00:00Z", "merkleRoot": "0x...", "allowAllClaimers": true } ``` ### Exceptions - **System.ArgumentNullException**: Thrown when the contract is null. - **System.ArgumentOutOfRangeException**: Thrown when the claim condition ID is less than 0. ``` -------------------------------- ### ThirdwebClient.Create Source: https://github.com/thirdweb-dev/dotnet/blob/main/llms.txt This method is used to create a new instance of the ThirdwebClient, which is the main entry point for interacting with the Thirdweb API. It allows for various configuration options, including client ID, secret key, bundle ID, timeouts, custom HTTP clients, SDK details, and RPC overrides. ```APIDOC ## ThirdwebClient.Create ### Description Creates a new instance of the ThirdwebClient for interacting with the Thirdweb API. ### Method `ThirdwebClient.Create` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```csharp var thirdwebClient = await ThirdwebClient.Create( clientId: "YOUR_CLIENT_ID", secretKey: "YOUR_SECRET_KEY", bundleId: "YOUR_BUNDLE_ID", fetchTimeoutOptions: new TimeoutOptions { RequestTimeout = TimeSpan.FromSeconds(30) }, // httpClient: new CustomHttpClient(), // Optional: provide your own HttpClient implementation sdkName: "MySDK", sdkOs: "Windows", sdkPlatform: "x64", sdkVersion: "1.0.0", rpcOverrides: new Dictionary { { 1, "YOUR_CUSTOM_RPC_URL" } } ); ``` ### Response #### Success Response (200) A new instance of `ThirdwebClient` is returned. #### Response Example ```json { "message": "Thirdweb client created successfully" } ``` ### Remarks This method is asynchronous and returns a Task. ### Properties of ThirdwebClient - **HttpClient** (`System.Net.Http.HttpClient`): Gets the HTTP client used by the Thirdweb client. - **ClientId** (`string`): Gets the client ID. - **Api** (`Thirdweb.Api.ThirdwebHttpClientWrapper`): Provides low-level interaction with https://api.thirdweb.com. ``` -------------------------------- ### ERC721 Get NFT Source: https://github.com/thirdweb-dev/dotnet/blob/main/llms.txt Retrieves the details of a specific ERC721 token, optionally including owner information. ```APIDOC ## GET /erc721/nft/{tokenId} ### Description Get the details of a specific ERC721 token. Optionally includes owner details. ### Method GET ### Endpoint /erc721/nft/{tokenId} ### Parameters #### Path Parameters - **tokenId** (System.Numerics.BigInteger) - Required - The ID of the token. #### Query Parameters - **fillOwner** (bool) - Optional - A boolean indicating whether to fill the owner details. Defaults to true. ### Request Example ```json { "tokenId": 1, "fillOwner": true } ``` ### Response #### Success Response (200) - **nft** (object) - An object containing the NFT details. - **id** (System.Numerics.BigInteger) - The token ID. - **owner** (string) - The owner's address (if fillOwner is true). - **metadata** (object) - The token's metadata. #### Response Example ```json { "nft": { "id": 1, "owner": "0x...", "metadata": { "name": "My NFT", "description": "A unique NFT" } } } ``` ### Exceptions - **System.ArgumentNullException**: Thrown when the contract is null. - **System.ArgumentOutOfRangeException**: Thrown when the token ID is less than 0. ``` -------------------------------- ### POST /wallets/solana Source: https://github.com/thirdweb-dev/dotnet/blob/main/llms.txt Create a new Solana wallet or return the existing wallet for a given label. Labels must be unique within your project. ```APIDOC ## POST /wallets/solana ### Description Create a new Solana wallet or return the existing wallet for a given label. Labels must be unique within your project. ### Method POST ### Endpoint /wallets/solana ### Parameters #### Request Body - **body** (Body21) - Required - The request body containing the wallet label. ### Request Example ```json { "label": "MyNewSolanaWallet" } ``` ### Response #### Success Response (200) - **address** (string) - The address of the created or existing Solana wallet. - **label** (string) - The label of the wallet. #### Response Example ```json { "address": "0xSolanaWalletAddress1", "label": "MyNewSolanaWallet" } ``` ### Error Handling - **ApiException**: A server-side error occurred. ``` -------------------------------- ### ERC721 Get Owned NFTs Source: https://github.com/thirdweb-dev/dotnet/blob/main/llms.txt Retrieves a list of NFTs owned by a specific address within a specified range. ```APIDOC ## GET /erc721/owned-nfts ### Description Get a list of NFTs owned by a specific address within a specified range. ### Method GET ### Endpoint /erc721/owned-nfts ### Parameters #### Query Parameters - **ownerAddress** (string) - Required - The address of the owner. - **startTokenId** (int) - Optional - The starting token ID (inclusive). Defaults to 0 if not specified. - **count** (int) - Optional - The number of NFTs to retrieve. Defaults to 100 if not specified. ### Request Example ```json { "ownerAddress": "0xabc...", "startTokenId": 0, "count": 10 } ``` ### Response #### Success Response (200) - **nfts** (array) - An array of NFT objects owned by the specified address. - Each object contains: - **id** (System.Numerics.BigInteger) - The token ID. - **metadata** (object) - The token's metadata. #### Response Example ```json { "nfts": [ { "id": 1, "metadata": { "name": "Owned NFT 1" } }, { "id": 5, "metadata": { "name": "Owned NFT 5" } } ] } ``` ### Exceptions - **System.ArgumentNullException**: Thrown when the contract or owner address is null. - **System.ArgumentException**: Thrown when the owner address is empty. ``` -------------------------------- ### Initiate Authentication in .NET Source: https://github.com/thirdweb-dev/dotnet/blob/main/llms.txt Initiates any authentication flow using the Thirdweb API. This method supports SMS, email, passkey, and SIWE. OAuth uses a separate endpoint, and custom/guest authentication can skip initiation. Requires `x-client-id` or `x-secret-key` header. ```csharp public async Task InitiateAuthenticationAsync(Thirdweb.Api.Body body); public async Task InitiateAuthenticationAsync(Thirdweb.Api.Body body, System.Threading.CancellationToken cancellationToken); ```