### Setup the Provider Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/src/app/bridge/page.mdx Wrap your application with the `ThirdwebProvider` ```tsx // app.tsx / _app.tsx import { ThirdwebProvider } from "thirdweb/react"; function App() { return ( ); } ``` -------------------------------- ### Complete Example Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/src/app/engine/v3/guides/session-keys/page.mdx A comprehensive example demonstrating the setup and execution of transactions with session keys. ```typescript import { generateAccount, smartWallet, sendTransaction, getContract, createThirdwebClient } from "thirdweb"; import { sepolia } from "thirdweb/chains"; import { getAllActiveSigners } from "thirdweb/extensions/erc4337"; import { Engine } from "thirdweb/engine"; async function executeTransactionWithSessionKey() { // Configuration const client = createThirdwebClient({ clientId: "your-client-id", secretKey: "your-secret-key" }); const sessionKeyAccountAddress = "0x..."; // Your session key address const targetAddress = "0x..."; // Target address for the final transaction try { // Step 1: Create personal account const personalAccount = await generateAccount({ client }); // Step 2: Configure smart wallet const smart = smartWallet({ chain: sepolia, sessionKey: { address: sessionKeyAccountAddress, permissions: { approvedTargets: "*", }, }, sponsorGas: true, }); // Step 3: Connect smart account const smartAccount = await smart.connect({ client, personalAccount, }); // Step 4: Verify session key const signers = await getAllActiveSigners({ contract: getContract({ address: smartAccount.address, chain: sepolia, client, }), }); const isSessionKeyActive = signers .map((s) => s.signer) .includes(sessionKeyAccountAddress); if (!isSessionKeyActive) { throw new Error("Session key is not active"); } // Step 5: Create server wallet const serverWallet = Engine.serverWallet({ address: sessionKeyAccountAddress, chain: sepolia, client, executionOptions: { entrypointVersion: "0.6", signerAddress: sessionKeyAccountAddress, smartAccountAddress: smartAccount.address, type: "ERC4337", }, vaultAccessToken: process.env.VAULT_TOKEN as string, }); // Step 6: Execute transaction const tx = await sendTransaction({ account: serverWallet, transaction: { chain: sepolia, client, to: targetAddress, value: 0n, }, }); console.log("Transaction successful:", tx.transactionHash); return tx; } catch (error) { console.error("Error executing transaction:", error); throw error; } } // Execute the function executeTransactionWithSessionKey() .then((tx) => console.log("Done!", tx.transactionHash)) .catch((error) => console.error("Failed:", error)); ``` -------------------------------- ### Unity SDK Installation Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/src/app/wallets/page.mdx Download the latest thirdweb Unity SDK and import the package into your Unity project. ```bash 1. Download the latest [thirdweb Unity SDK](https://github.com/thirdweb-dev/unity/releases) (.unitypackage file) 2. Import the package into your Unity project via Assets > Import Package > Custom Package ``` -------------------------------- ### Installation Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/src/app/bridge/page.mdx Install the thirdweb SDK in your TypeScript project. ```bash npm i thirdweb yarn add thirdweb pnpm i thirdweb bun i thirdweb ``` -------------------------------- ### install example Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/public/llms-full.txt Example of how to install the ClaimableERC20 module. ```typescript import { ClaimableERC20 } from "thirdweb/modules";\n\nconst transaction = ClaimableERC20.install({\n contract: coreContract,\n account: account,\n params: {\n primarySaleRecipient: ...,\n },\n});\n\nawait sendTransaction({\n transaction,\n account,\n}); ``` -------------------------------- ### Create a new project Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/src/app/tokens/build/get-started/page.mdx To get started with the Solidity SDK, run the following command to create a new project: ```bash npx thirdweb create contract ``` -------------------------------- ### install Example Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/public/llms-full.txt Example usage of the install function to install the RoyaltyERC1155 module. ```typescript import { RoyaltyERC1155 } from "thirdweb/modules"; const transaction = RoyaltyERC1155.install({ contract: coreContract, account: account, params: { royaltyRecipient: ..., royaltyBps: ..., transferValidator: ..., }, }); await sendTransaction({ transaction, account, }); ``` -------------------------------- ### Go Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/src/app/engine/v3/get-started/page.mdx Example of sending a transaction using Go. ```go jsonData, _ := json.Marshal(requestBody) // Create the HTTP request req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData)) req.Header.Set("Content-Type", "application/json") req.Header.Set("x-secret-key", "") req.Header.Set("x-vault-access-token", "") // Send the request client := &http.Client{} resp, err := client.Do(req) if err != nil { fmt.Println("Error:", err) return } defer resp.Body.Close() // Process the response var result map[string]interface{} json.NewDecoder(resp.Body).Decode(&result) fmt.Println("Response:", result) } ``` ``` -------------------------------- ### Install Forge Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/src/app/tokens/build/get-started/page.mdx Install the contracts package into your existing Solidity project using Forge. ```bash forge install https://github.com/thirdweb-dev/contracts ``` -------------------------------- ### Using Base Contracts Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/src/app/tokens/build/get-started/page.mdx Example of inheriting and using a base contract with constructor arguments. ```solidity // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@thirdweb-dev/contracts/base/ERC721Base.sol"; contract MyNFT is ERC721Base { constructor( address _defaultAdmin, string memory _name, string memory _symbol, address _royaltyRecipient, uint128 _royaltyBps ) ERC721Base(_defaultAdmin, _name, _symbol, _royaltyRecipient, _royaltyBps) {} } ``` -------------------------------- ### Install Published Extension Example Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/public/llms-full.txt Example of installing a published extension on a dynamic contract. ```typescript import { installPublishedExtension } from "thirdweb/dynamic-contracts"; const transaction = installPublishedExtension({ client, chain, account, contract, extensionName: "MyExtension", publisherAddress: "0x...", }); await sendTransaction({ transaction, account }); ``` ```typescript function installPublishedExtension( options: InstallPublishedExtensionOptions, ): PreparedTransaction; ``` -------------------------------- ### Send a transaction using Go Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/src/app/engine/v3/get-started/page.mdx Example of sending a transaction using Go. ```go package main import ( "bytes" "encoding/json" "fmt" "net/http" ) func main() { url := "https://engine.thirdweb.com/v1/write/contract" // Create the request payload type Param struct { ContractAddress string `json:"contractAddress"` Method string `json:"method"` Params []string `json:"params"` } type RequestBody struct { ExecutionOptions struct { From string `json:"from"` ChainId string `json:"chainId"` } `json:"executionOptions"` Params []Param `json:"params"` } requestBody := RequestBody{ Params: []Param{ { ContractAddress: "0x...", Method: "function mintTo(address to, uint256 amount)", Params: []string{"0x...", "100"}, }, }, } requestBody.ExecutionOptions.From = "" requestBody.ExecutionOptions.ChainId = "84532" ``` -------------------------------- ### install Example Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/public/llms-full.txt Installs the TransferableERC721 module on a core contract. ```typescript import { TransferableERC721 } from "thirdweb/modules"; const transaction = TransferableERC721.install({ contract: coreContract, account: account, }); await sendTransaction({ transaction, account, }); ``` -------------------------------- ### Complete Example: Setup and Use Session Key with ERC-7702 Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/src/app/engine/v3/guides/session-keys/page.mdx A comprehensive example demonstrating the setup and usage of a session key with ERC-7702, including creating a smart EOA, deploying the account, creating the session key, and executing a transaction. ```typescript import { createThirdwebClient, getContract, sendTransaction, prepareTransaction } from "thirdweb"; import { sepolia } from "thirdweb/chains"; import { inAppWallet, createSessionKey } from "thirdweb/wallets/in-app"; import { Engine } from "thirdweb/engine"; async function setupSessionKeyWith7702() { // Configuration const client = createThirdwebClient({ clientId: "your-client-id", secretKey: "your-secret-key" }); const sessionKeyAccountAddress = "0x..."; // Your session key address try { // Step 1: Create 7702 Smart EOA const wallet = inAppWallet({ executionMode: { mode: "EIP7702", sponsorGas: true, }, }); const account = await wallet.connect({ chain: sepolia, client: client, strategy: "google", }); console.log("Smart EOA created:", account.address); // Step 2: Deploy/upgrade the account await sendTransaction({ account: account, transaction: prepareTransaction({ chain: sepolia, client: client, to: account.address, value: 0n, }), }); // Step 3: Get account contract const accountContract = getContract({ address: account.address, chain: sepolia, client: client, }); // Step 4: Create session key const sessionTx = await sendTransaction({ account: account, transaction: createSessionKey({ account: account, contract: accountContract, sessionKeyAddress: sessionKeyAccountAddress, durationInSeconds: 86400, // 1 day grantFullPermissions: true, }), }); console.log("Session key created:", sessionTx.transactionHash); // Step 5: Use the session key with Engine const serverWallet = Engine.serverWallet({ address: sessionKeyAccountAddress, chain: sepolia, client: client, vaultAccessToken: process.env.VAULT_TOKEN as string, }); // Execute a transaction with the session key const tx = await sendTransaction({ account: serverWallet, transaction: prepareTransaction({ chain: sepolia, client: client, to: "0x...", // Target address value: 0n, }), }); console.log("Transaction successful:", tx.transactionHash); return tx; } catch (error) { console.error("Error:", error); throw error; } } // Execute the function setupSessionKeyWith7702() .then((tx) => console.log("Done!", tx.transactionHash)) .catch((error) => console.error("Failed:", error)); ``` -------------------------------- ### Example operation: Get contract metadata Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/src/app/dotnet/api/quickstart/page.mdx Fetch contract metadata, including ABI and compiler version, using the authenticated client. This pattern applies to other API namespaces as well. ```csharp // using Newtonsoft.Json; var metadata = await client.Api.GetContractMetadataAsync( chainId: 1, address: "0xBd3531dA5CF5857e7CfAA92426877b022e612cf8" ); Console.WriteLine($"ABI: {JsonConvert.SerializeObject(metadata.Result.Output.Abi, Formatting.Indented)}"); Console.WriteLine($"Compiler version: {metadata.Result.Compiler.Version}"); ``` -------------------------------- ### install Example Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/public/llms-full.txt Installs the RoyaltyERC721 module on a core contract. ```typescript import { RoyaltyERC721 } from "thirdweb/modules"; const transaction = RoyaltyERC721.install({ contract: coreContract, account: account, params: { royaltyRecipient: ..., royaltyBps: ..., transferValidator: ..., }, }); await sendTransaction({ transaction, account, }); ``` -------------------------------- ### Get Offer Example Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/public/llms-full.txt Example of how to retrieve an offer using the SDK. ```typescript import { getOffer } from "thirdweb/extensions/marketplace"; const listing = await getOffer({ contract, listingId: 1n }); ``` -------------------------------- ### Inheriting Extensions Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/src/app/tokens/build/get-started/page.mdx Example of importing and inheriting extensions like Permissions into a custom smart contract. ```solidity // SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport "@thirdweb-dev/contracts/base/ERC721Base.sol";\nimport "@thirdweb-dev/contracts/extension/Permissions.sol";\n\ncontract MyNFT is ERC721Base, Permissions {\n constructor(\n address _defaultAdmin,\n string memory _name,\n string memory _symbol,\n address _royaltyRecipient,\n uint128 _royaltyBps\n ) ERC721Base(_defaultAdmin, _name, _symbol, _royaltyRecipient, _royaltyBps) {} } ``` -------------------------------- ### Install OpenEditionMetadataERC721 Module Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/public/llms-full.txt Example of installing the OpenEditionMetadataERC721 module. ```typescript import { OpenEditionMetadataERC721 } from "thirdweb/modules"; const transaction = OpenEditionMetadataERC721.install({ contract: coreContract, account: account, }); await sendTransaction({ transaction, account, }); ``` ```typescript function install(options: { account: Account; contract: Readonly; params?: { publisher?: string }; }): PreparedTransaction; ``` -------------------------------- ### ClaimableERC721.install Example Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/public/llms-full.txt Example of installing the ClaimableERC721 module on a core contract. ```typescript import { ClaimableERC721 } from "thirdweb/modules"; const transaction = ClaimableERC721.install({ contract: coreContract, account: account, params: { primarySaleRecipient: ..., }, }); await sendTransaction({ transaction, account, }); ``` -------------------------------- ### Set up the Client, Provider and ConnectButton Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/src/app/wallets/quickstart/page.mdx Set up the client, provider, and ConnectButton for your application. ```tsx import { createThirdwebClient } from "thirdweb"; import { ThirdwebProvider, ConnectButton } from "thirdweb/react"; export const client = createThirdwebClient({ clientId: }); export default function App() { return ( ); } ``` -------------------------------- ### Set up the Client Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/src/app/bridge/page.mdx First, create a client instance to connect with thirdweb services: ```typescript import { createThirdwebClient } from "thirdweb"; // - clientId for client-side applications // - secretKey for server-side applications const client = createThirdwebClient({ clientId: "YOUR_CLIENT_ID", // Get from your thirdweb dashboard }); ``` -------------------------------- ### C# Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/src/app/engine/v3/get-started/page.mdx Example of sending a transaction using C#. ```csharp using System; using System.Net.Http; using System.Text; using System.Text.Json; using System.Threading.Tasks; class Program { static async Task Main() { var url = "https://engine.thirdweb.com/v1/write/contract"; var requestData = new { executionOptions = new { from = "", chainId = "84532" }, @params = new[] { new { contractAddress = "0x...", method = "function mintTo(address to, uint256 amount)", @params = new[] { "0x...", "100" } } } }; var json = JsonSerializer.Serialize(requestData); var content = new StringContent(json, Encoding.UTF8, "application/json"); using var httpClient = new HttpClient(); httpClient.DefaultRequestHeaders.Add("x-secret-key", ""); httpClient.DefaultRequestHeaders.Add("x-vault-access-token", ""); var response = await httpClient.PostAsync(url, content); var responseContent = await response.Content.ReadAsStringAsync(); Console.WriteLine(responseContent); } } ``` -------------------------------- ### Start Local Development Server Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/README.md Starts the local development server using pnpm. ```bash pnpm dev ``` -------------------------------- ### Setup Imports and Configuration Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/src/app/engine/v3/guides/session-keys/page.mdx Import necessary functions and configure your thirdweb client. ```typescript import { createThirdwebClient, getContract, sendTransaction, prepareTransaction } from "thirdweb"; import { sepolia } from "thirdweb/chains"; import { inAppWallet, createSessionKey } from "thirdweb/wallets/in-app"; // Configure your client const client = createThirdwebClient({ clientId: "your-client-id", secretKey: "your-secret-key" // Only use in server environments }); // Your session key account address const sessionKeyAccountAddress = "0x..."; // Replace with your session key address ``` -------------------------------- ### Send a transaction using Python Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/src/app/engine/v3/get-started/page.mdx Example of sending a transaction using Python with the requests library. ```python import requests import json url = "https://engine.thirdweb.com/v1/write/contract" headers = { "Content-Type": "application/json", "x-secret-key": "", "x-vault-access-token": "" } payload = { "executionOptions": { "from": "", "chainId": "84532" }, "params": [ { "contractAddress": "0x...", "method": "function mintTo(address to, uint256 amount)", "params": ["0x...", "100"] } ] } response = requests.post(url, headers=headers, json=payload) result = response.json() ``` -------------------------------- ### installModule Example Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/public/llms-full.txt Example of how to prepare a transaction to install a module using the installModule function and send it. ```typescript import { sendTransaction } from "thirdweb"; import { installModule } from "thirdweb/extensions/modules"; const transaction = installModule({ contract, moduleContract: ..., data: ..., overrides: { ... } }); // Send the transaction await sendTransaction({ transaction, account }); ``` ```typescript function installModule( options: BaseTransactionOptions< | InstallModuleParams | { asyncParams: () => Promise } >, ): PreparedTransaction; ``` -------------------------------- ### Smart Wallet Upgrade Example Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/src/app/unity/v6/migration-guide/page.mdx Demonstrates how to upgrade to a smart wallet using the v6 APIs, showing the use of PrivateKeyWallet and the UpgradeToSmartWallet method. ```csharp var personalWallet = await PrivateKeyWallet.Generate(client); var smartWallet = await ThirdwebManager.Instance.UpgradeToSmartWallet( personalWallet, chainId: new BigInteger(421614), smartWalletOptions: new SmartWalletOptions(sponsorGas: true) ); ``` -------------------------------- ### Send a transaction using JavaScript Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/src/app/engine/v3/get-started/page.mdx Example of sending a transaction using JavaScript with the fetch API. ```typescript const response = await fetch( "https://engine.thirdweb.com/v1/write/contract", { method: "POST", headers: { "Content-Type": "application/json", "x-secret-key": "", "x-vault-access-token": "", }, body: JSON.stringify({ executionOptions: { from: "", chainId: "84532", }, params: [ { contractAddress: "0x...", method: "function mintTo(address to, uint256 amount)", params: ["0x...", "100"], }, ], }), } ); ``` -------------------------------- ### Buy From Listing Example Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/public/llms-full.txt Example of how to buy from a listing. ```typescript import { buyFromListing } from "thirdweb/extensions/marketplace"; import { sendTransaction } from "thirdweb"; const transaction = buyFromListing({ contract, listingId: 1n, quantity: 1n, recipient: "0x...", }); await sendTransaction({ transaction, account }); ``` -------------------------------- ### Send a transaction using Curl Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/src/app/engine/v3/get-started/page.mdx Example of sending a transaction using the Curl command-line tool. ```bash curl -X POST "https://engine.thirdweb.com/v1/write/contract" \ -H "Content-Type: application/json" \ -H "x-secret-key: " \ -H "x-vault-access-token: " \ -d '{ "executionOptions": { "from": "", "chainId": "84532" }, "params": [ { "contractAddress": "0x...", "method": "function mintTo(address to, uint256 amount)", "params": ["0x...", "100"] } ] }' ``` -------------------------------- ### Setup Script Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/src/app/contracts/arbitrum-stylus/zk-mint/page.mdx Run the setup script to generate oracle keys and build the ZK circuit. This script generates a secret key, injects it into the circuit, compiles the circuit, and generates necessary keys. ```bash chmod +x setup.sh ./setup.sh ``` -------------------------------- ### Example Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/public/llms-full.txt Create a new server wallet. ```typescript import { Engine } from "thirdweb"; const serverWallet = await Engine.createServerWallet({ client, label: "My Server Wallet", }); console.log(serverWallet.address); console.log(serverWallet.smartAccountAddress); ``` ```typescript function createServerWallet( params: CreateServerWalletArgs, ): Promise<{ address: string; label?: string; smartAccountAddress?: string; }>; ``` -------------------------------- ### Using Extension Functions Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/src/app/tokens/build/get-started/page.mdx Example demonstrating how to use functions provided by an extension (Permissions) to modify smart contract behavior, specifically for minting. ```solidity // SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport "@thirdweb-dev/contracts/base/ERC721Base.sol";\nimport "@thirdweb-dev/contracts/extension/Permissions.sol";\n\ncontract MyNFT is ERC721Base, Permissions {\n bytes32 private constant MINTER_ROLE = keccak256("MINTER_ROLE");\n\n constructor(\n address _defaultAdmin,\n string memory _name,\n string memory _symbol,\n address _royaltyRecipient,\n uint128 _royaltyBps\n ) ERC721Base(_defaultAdmin, _name, _symbol, _royaltyRecipient, _royaltyBps) {} \n /**\n * `_canMint` is a function available in `ERC721Base`.\n *\n * It is called every time a wallet tries to mint NFTs on this\n * contract, and lets you define the condition in which an\n * attempt to mint NFTs should be permitted, or rejected.\n *\n * By default, `ERC721Base` only lets the contract's owner mint\n * NFTs. Here, we override that functionality.\n *\n * We use the `Permissions` extension to specify that anyone holding\n * "MINTER_ROLE" should be able to mint NFTs.\n */\n function _canMint() internal view override returns (bool) {\n return hasRole(MINTER_ROLE, msg.sender);\n }\n} ``` -------------------------------- ### Example Usage Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/public/llms-full.txt Example of how to retrieve all offers using the getAllOffers function. ```typescript import { getAllOffers } from "thirdweb/extensions/marketplace"; const listings = await getAllOffers({ contract, start: 0, count: 10, }); ``` -------------------------------- ### Installation and Development Commands Source: https://github.com/thirdweb-dev/js/blob/main/apps/wagmi-demo/README.md Commands to install dependencies and run the development server for the demo application. ```bash pnpm install pnpm dev ``` -------------------------------- ### Instantiate an authenticated client Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/src/app/dotnet/api/quickstart/page.mdx Create a reusable ThirdwebClient instance with your backend secret key to access all raw Thirdweb API surfaces. ```csharp // Program.cs / dependency container registration var client = ThirdwebClient.Create(secretKey: Environment.GetEnvironmentVariable("THIRDWEB_SECRET_KEY")); ``` -------------------------------- ### Overriding Parent Functions Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/src/app/tokens/build/get-started/page.mdx Example of overriding a parent contract's function (`mintTo`) to add custom logic, such as restricting minting to one NFT per wallet. ```solidity // SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport "@thirdweb-dev/contracts/base/ERC721Base.sol";\nimport "@thirdweb-dev/contracts/extension/Permissions.sol";\n\ncontract MyNFT is ERC721Base, Permissions {\n constructor(\n address _defaultAdmin,\n string memory _name,\n string memory _symbol,\n address _royaltyRecipient,\n uint128 _royaltyBps\n ) ERC721Base(_defaultAdmin, _name, _symbol, _royaltyRecipient, _royaltyBps) {} \n function mintTo(address _to, string memory _tokenURI) public override {\n require(balanceOf(_to) < 1, "only 1 NFT per wallet!");\n super.mintTo(_to, _tokenURI);\n }\n} ``` -------------------------------- ### Example Usage Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/public/llms-full.txt Example of how to use getAllListings to retrieve all direct listings based on the provided options. ```typescript import { getAllListings } from "thirdweb/extensions/marketplace"; const listings = await getAllListings({ contract, start: 0, count: 10, }); ``` ```typescript function getAllListings( options: BaseTransactionOptions, ): Promise>; ``` -------------------------------- ### Implementing User Wallets in Unity (Email Login) Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/src/app/wallets/page.mdx Enable email login in Unity using the InAppWalletOptions. ```csharp public async void ConnectWithEmail(string email) { try { var inAppWalletOptions = new InAppWalletOptions(email: "myepicemail@domain.id"); var options = new WalletOptions( provider: WalletProvider.InAppWallet, chainId: 1, inAppWalletOptions: inAppWalletOptions ); var wallet = await ThirdwebManager.Instance.ConnectWallet(options); } catch (System.Exception e) { Debug.LogError("Error connecting wallet: " + e.Message); } } ``` -------------------------------- ### Install ClaimableERC1155 Module Example Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/public/llms-full.txt Example of installing the ClaimableERC1155 module on a core contract. ```typescript import { ClaimableERC1155 } from "thirdweb/modules"; const transaction = ClaimableERC1155.install({ contract: coreContract, account: account, params: { primarySaleRecipient: ..., }, }); await sendTransaction({ transaction, account, }); ``` ```typescript function install(options: { account: Account; contract: Readonly; params: EncodeBytesOnInstallParams & { publisher?: string }; }): PreparedTransaction; ``` -------------------------------- ### Encode Install Data Example Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/public/llms-full.txt Example of encoding install data for the ClaimableERC1155 module. ```typescript function encodeInstall( params: EncodeBytesOnInstallParams, ): `0x${string}`; ``` -------------------------------- ### Generate a bridge quote Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/src/app/bridge/page.mdx To get started, lets generate a quote for 10 USDC on Optimism, paid with USDT on Arbitrum. ```typescript import { Bridge, NATIVE_TOKEN_ADDRESS, toWei } from "thirdweb"; // Quote to buy 10 USDC on Optimism, paid with USDT on Arbitrum const preparedQuote = await Bridge.Buy.prepare({ originChainId: 42161, originTokenAddress: "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9", // USDT on Arbitrum destinationChainId: 10, destinationTokenAddress: "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85", // USDC on Optimism amount: 10_000_000n, // 10 USDC in wei (USDC has 6 decimals) sender: "0x2a4f24F935Eb178e3e7BA9B53A5Ee6d8407C0709", receiver: "0x2a4f24F935Eb178e3e7BA9B53A5Ee6d8407C0709", client, }); ``` -------------------------------- ### getInitBytecodeWithSalt Example Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/public/llms-full.txt Generates the initialization bytecode with salt for a contract deployment. ```typescript import { getInitBytecodeWithSalt } from "thirdweb/utils"; const initBytecodeWithSalt = getInitBytecodeWithSalt({ bytecode, encodedArgs, salt, }); ``` ```typescript function getInitBytecodeWithSalt( options: GetInitiBytecodeWithSaltOptions, ): `0x${string}`; ``` -------------------------------- ### Run the Application Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/src/app/contracts/arbitrum-stylus/zk-mint/page.mdx Navigate to the app directory and start the development server. ```bash cd app pnpm dev # Visit http://localhost:3000 ``` -------------------------------- ### Setup Imports and Configuration Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/src/app/wallets/session-keys/page.mdx Imports necessary functions from the thirdweb SDK and configures the client and session key details. ```typescript import { generateAccount, smartWallet, sendTransaction, getContract, createThirdwebClient } from "thirdweb"; import { sepolia } from "thirdweb/chains"; import { getAllActiveSigners } from "thirdweb/extensions/erc4337"; import { Engine } from "thirdweb/engine"; // Configure your client const client = createThirdwebClient({ clientId: "your-client-id", secretKey: "your-secret-key" // Only use in server environments }); // Your session key account address const sessionKeyAccountAddress = "0x..."; // Replace with your session key address (server wallet) // Target address for transactions const targetAddress = "0x..."; // Replace with your target address ``` -------------------------------- ### Get Wallet Capabilities Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/public/llms-full.txt Example of how to get the capabilities of a wallet. ```typescript import { getCapabilities } from "thirdweb/wallets/eip5792"; const wallet = createWallet("com.coinbase.wallet"); const capabilities = await getCapabilities({ wallet }); ``` ```typescript function getCapabilities( options: GetCapabilitiesOptions, ): Promise<{ message?: string }>; ``` -------------------------------- ### Example Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/public/llms-full.txt Example of how to use injectedProvider to get the Metamask provider. ```typescript import { injectedProvider } from "thirdweb/wallets"; const metamaskProvider = injectedProvider("io.metamask"); if (metamaskProvider) { console.log("Metamask is installed"); } ``` -------------------------------- ### React Application Quick Start Source: https://github.com/thirdweb-dev/js/blob/main/README.md Example of setting up the thirdweb SDK in a React application. ```typescript import { createThirdwebClient } from "thirdweb"; import { ConnectButton, useActiveAccount } from "thirdweb/react"; const client = createThirdwebClient({ clientId: "YOUR_CLIENT_ID", }); function App() { const account = useActiveAccount(); console.log("Connected as", account?.address); return ; } ``` -------------------------------- ### claimConditionsUpdatedEvent Example Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/public/llms-full.txt Example of how to get ClaimConditionsUpdated events from a contract. ```typescript import { getContractEvents } from "thirdweb"; import { claimConditionsUpdatedEvent } from "thirdweb/extensions/erc20"; const events = await getContractEvents({ contract, events: [claimConditionsUpdatedEvent()], }); ``` -------------------------------- ### Example Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/public/llms-full.txt List all server wallets. ```typescript import { Engine } from "thirdweb"; const serverWallets = await Engine.getServerWallets({ client, }); console.log(serverWallets); ``` ```typescript function getServerWallets( params: GetServerWalletsArgs, ): Promise< Array<{ address: string; label?: string; smartAccountAddress?: string; }> >; ``` -------------------------------- ### Example Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/public/llms-full.txt Example usage of transferSingleEvent to get contract events. ```typescript import { getContractEvents } from "thirdweb"; import { transferSingleEvent } from "thirdweb/extensions/erc1155"; const events = await getContractEvents({ contract, events: [ transferSingleEvent({ _operator: ..., _from: ..., _to: ..., }), ], }); ``` ```typescript function transferSingleEvent( filters: Partial, ): PreparedEvent<{ readonly inputs: readonly [ { readonly indexed: true; readonly name: "_operator"; readonly type: "address"; }, { readonly indexed: true; readonly name: "_from"; readonly type: "address"; }, { readonly indexed: true; readonly name: "_to"; readonly type: "address"; }, { readonly name: "tokenId"; readonly type: "uint256" }, { readonly name: "_value"; readonly type: "uint256" }, ]; readonly name: "TransferSingle"; readonly type: "event"; }>; ``` -------------------------------- ### Connection Hooks Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/src/app/wallets/page.mdx For more customized implementations, use the connection hooks like useConnect and inAppWallet. ```tsx import { useConnect, useActiveAccount } from "thirdweb/react"; import { inAppWallet } from "thirdweb/wallets"; // initialize a wallet const wallet = inAppWallet(); function CustomWalletUI() { const { connect } = useConnect(); const account = useActiveAccount(); console.log("connected to", account?.address); const onClick = () => { connect(async () => { await wallet.connect({ client, // your thirdweb client strategy: "google", // or any other auth strategy }); return wallet; }); }; return ( ); } ``` -------------------------------- ### Example Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/public/llms-full.txt Example usage of transferBatchEvent to get contract events. ```typescript import { getContractEvents } from "thirdweb"; import { transferBatchEvent } from "thirdweb/extensions/erc1155"; const events = await getContractEvents({ contract, events: [ transferBatchEvent({ _operator: ..., _from: ..., _to: ..., }), ], }); ``` ```typescript function transferBatchEvent( filters: Partial, ): PreparedEvent<{ readonly inputs: readonly [ { readonly indexed: true; readonly name: "_operator"; readonly type: "address"; }, { readonly indexed: true; readonly name: "_from"; readonly type: "address"; }, { readonly indexed: true; readonly name: "_to"; readonly type: "address"; }, { readonly name: "tokenIds"; readonly type: "uint256[]" }, { readonly name: "_values"; readonly type: "uint256[]" }, ]; readonly name: "TransferBatch"; readonly type: "event"; }>; ``` -------------------------------- ### Example Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/public/llms-full.txt Example of how to use createAndSignUserOp to create and sign a user operation. ```typescript import { createAndSignUserOp } from "thirdweb/wallets/smart"; const userOp = await createAndSignUserOp({ client, adminAccount, smartWalletOptions, transactions, }); ``` -------------------------------- ### Example Usage Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/public/llms-full.txt Example of how to get NewBid events from a contract. ```typescript import { getContractEvents } from "thirdweb"; import { newBidEvent } from "thirdweb/extensions/marketplace"; const events = await getContractEvents({ contract, events: [ newBidEvent({ auctionId: ..., bidder: ..., assetContract: ..., }) ], }); ``` -------------------------------- ### BuyerApprovedForListing Event Example Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/public/llms-full.txt Example of how to get BuyerApprovedForListing events. ```typescript import { getContractEvents, } from "thirdweb"; import { buyerApprovedForListingEvent, } from "thirdweb/extensions/marketplace"; const events = await getContractEvents({ contract, events: [ buyerApprovedForListingEvent({ listingId: ..., buyer: ..., }), ], }); ``` -------------------------------- ### MintableERC20.install Example Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/public/llms-full.txt Installs the MintableERC20 module on a core contract. ```typescript import { MintableERC20 } from "thirdweb/modules"; const transaction = MintableERC20.install({ contract: coreContract, account: account, params: { primarySaleRecipient: ..., }, }); await sendTransaction({ transaction, account, }); ``` -------------------------------- ### Example Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/public/llms-full.txt Example of how to use getSocialIcon to get social media icons. ```tsx const googleIcon = getSocialIcon("google"); const appleIcon = getSocialIcon("apple"); ``` -------------------------------- ### React Native - Create a Client Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/src/app/wallets/page.mdx Create a client instance for your React Native application. ```typescript import { createThirdwebClient } from "thirdweb"; export const client = createThirdwebClient({ clientId: "YOUR_CLIENT_ID", // Get from your thirdweb dashboard }); ``` -------------------------------- ### Example Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/public/llms-full.txt Example of how to use bundleUserOp to bundle a user operation. ```typescript import { bundleUserOp } from "thirdweb/wallets/smart"; const userOpHash = await bundleUserOp({ userOp, options, }); ``` -------------------------------- ### privateKeyToAccount Example Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/public/llms-full.txt Example of how to get an Account object from a private key. ```typescript import { privateKeyToAccount } from "thirdweb/wallets"; const wallet = privateKeyToAccount({ client, privateKey: "...", }); ``` -------------------------------- ### Interact with Smart Contracts Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/src/app/dotnet/getting-started/page.mdx Demonstrates how to read data from a smart contract using the Thirdweb .NET SDK. ```csharp var contract = await ThirdwebContract.Create(client: client, address: "contractAddress", chain: chainId); var readResult = await contract.Read(contract, "methodName"); Console.WriteLine($"Contract read result: {readResult}"); ``` -------------------------------- ### PoolCreated Event Example Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/public/llms-full.txt Example of how to get PoolCreated events from a contract. ```typescript import { getContractEvents } from "thirdweb"; import { poolCreatedEvent } from "thirdweb/extensions/uniswap"; const events = await getContractEvents({ contract, events: [ poolCreatedEvent({ token0: ..., token1: ..., sender: ..., }) ], }); ``` ```typescript function poolCreatedEvent( filters: Partial, ): PreparedEvent<{ readonly inputs: readonly [ { readonly indexed: true; readonly name: "token0"; readonly type: "address"; }, { readonly indexed: true; readonly name: "token1"; readonly type: "address"; }, { readonly name: "fee"; readonly type: "uint24" }, { readonly name: "tickLower"; readonly type: "int24" }, { readonly name: "tickUpper"; readonly type: "int24" }, { readonly name: "liquidity"; readonly type: "uint128" }, { readonly indexed: true; readonly name: "sender"; readonly type: "address"; }, ]; readonly name: "PoolCreated"; readonly type: "event"; }>; ``` -------------------------------- ### signerPermissionsUpdatedEvent Example Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/public/llms-full.txt Example of how to use signerPermissionsUpdatedEvent to get contract events. ```typescript import { getContractEvents } from "thirdweb"; import { signerPermissionsUpdatedEvent } from "thirdweb/extensions/erc4337"; const events = await getContractEvents({ contract, events: [ signerPermissionsUpdatedEvent({ authorizingSigner: ..., targetSigner: ..., }) ], }); ``` ```typescript function signerPermissionsUpdatedEvent( filters: Partial, ): PreparedEvent<{ readonly inputs: readonly [ { readonly indexed: true; readonly name: "authorizingSigner"; readonly type: "address"; }, { readonly indexed: true; readonly name: "targetSigner"; readonly type: "address"; }, { readonly components: readonly [ { readonly name: "signer"; readonly type: "address" }, { readonly name: "isAdmin"; readonly type: "uint8" }, { readonly name: "approvedTargets"; readonly type: "address[]"; }, { readonly name: "nativeTokenLimitPerTransaction"; readonly type: "uint256"; }, { readonly name: "permissionStartTimestamp"; readonly type: "uint128"; }, { readonly name: "permissionEndTimestamp"; readonly type: "uint128"; }, { readonly name: "reqValidityStartTimestamp"; readonly type: "uint128"; }, { readonly name: "reqValidityEndTimestamp"; readonly type: "uint128"; }, { readonly name: "uid"; readonly type: "bytes32" }, ]; readonly name: "permissions"; readonly type: "tuple"; }, ]; readonly name: "SignerPermissionsUpdated"; readonly type: "event"; }>; ``` -------------------------------- ### Create Account Example Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/public/llms-full.txt Example of creating an account using the createAccount function. ```typescript import { sendTransaction } from "thirdweb"; import { createAccount } from "thirdweb/extensions/erc4337"; const transaction = createAccount({ contract, admin: ..., data: ..., overrides: { ... } }); // Send the transaction await sendTransaction({ transaction, account }); ``` ```typescript function createAccount( options: BaseTransactionOptions< | CreateAccountParams | { asyncParams: () => Promise } >, ): PreparedTransaction; ``` -------------------------------- ### DEPLOY.prepareDirectDeployTransaction Example Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/public/llms-full.txt An example of preparing a direct deploy transaction with ABI and constructor parameters. ```typescript import { prepareDirectDeployTransaction } from "thirdweb/deploys"; import { ethereum } from "thirdweb/chains"; const tx = prepareDirectDeployTransaction({ client, chain: ethereum, bytecode: "0x...", constructorAbi: { inputs: [{ type: "uint256", name: "value" }], type: "constructor", }, constructorParams: [123], }); ``` -------------------------------- ### Get All Signers Example Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/public/llms-full.txt Example of calling the getAllSigners function on the contract. ```typescript import { getAllSigners } from "thirdweb/extensions/erc4337"; const result = await getAllSigners({ contract, }); ``` ```typescript function getAllSigners(options: BaseTransactionOptions) : Promise; endTimestamp: bigint; nativeTokenLimitPerTransaction: bigint; signer: string; startTimestamp: bigint }>> ``` -------------------------------- ### .NET Using In-App Wallets Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/src/app/wallets/page.mdx Create wallets with email authentication in .NET. ```csharp var wallet = await InAppWallet.Create(client: client, email: "userEmail"); await wallet.SendOTP(); // and fetch the otp var address = await wallet.LoginWithOtp("userEnteredOTP"); // try catch and retry if needed ``` -------------------------------- ### Get All Admins Example Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/public/llms-full.txt Example of calling the getAllAdmins function on the contract. ```typescript import { getAllAdmins } from "thirdweb/extensions/erc4337"; const result = await getAllAdmins({ contract, }); ``` ```typescript function getAllAdmins(options: BaseTransactionOptions) : Promise> ``` -------------------------------- ### Get All Accounts Example Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/public/llms-full.txt Example of calling the getAllAccounts function on the contract. ```typescript import { getAllAccounts } from "thirdweb/extensions/erc4337"; const result = await getAllAccounts({ contract, }); ``` ```typescript function getAllAccounts(options: BaseTransactionOptions) : Promise> ``` -------------------------------- ### Get Accounts Example Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/public/llms-full.txt Example of calling the getAccounts function on the contract. ```typescript import { getAccounts } from "thirdweb/extensions/erc4337"; const result = await getAccounts({ contract, start: ..., end: ..., }); ``` ```typescript function getAccounts(options: BaseTransactionOptions) : Promise> ``` -------------------------------- ### Backend Application Quick Start Source: https://github.com/thirdweb-dev/js/blob/main/README.md Example of setting up and using the thirdweb SDK in a backend application. ```typescript import { createThirdwebClient, Engine } from "thirdweb"; const client = createThirdwebClient({ secretKey: "YOUR_SECRET_KEY", }); const wallet = Engine.serverWallet({ client, address: "0x...", }); const transaction = transfer({ contract: getContract({ client, address: "0x...", // token contract chain: defineChain(1), }), to: "0x...", // recipient amount: "0.01", // amount in tokens }); await wallet.enqueueTransaction({ transaction, }); ``` -------------------------------- ### ERC721.approvalForAllEvent Example Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/public/llms-full.txt Example of how to get ApprovalForAll events from an ERC721 contract. ```typescript import { getContractEvents } from "thirdweb"; import { approvalForAllEvent } from "thirdweb/extensions/erc721"; const events = await getContractEvents({ contract, events: [ approvalForAllEvent({ owner: ..., operator: ..., }) ], }); ``` ```typescript function approvalForAllEvent( filters: Partial, ): PreparedEvent<{ readonly inputs: readonly [ { readonly indexed: true; readonly name: "owner"; readonly type: "address"; }, { readonly indexed: true; readonly name: "operator"; readonly type: "address"; }, { readonly name: "approved"; readonly type: "bool" }, ]; readonly name: "ApprovalForAll"; readonly type: "event"; }>; ``` -------------------------------- ### Create a Client Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/src/app/bridge/page.mdx First, create a client file for reuse throughout your app. You can get your clientId by creating a project in the [thirdweb dashboard](https://thirdweb.com/team) ```typescript // thirdwebClient.ts import { createThirdwebClient } from "thirdweb"; export const client = createThirdwebClient({ clientId: "YOUR_CLIENT_ID", // Get from your thirdweb dashboard }); ``` -------------------------------- ### createWalletAdapter Example Source: https://github.com/thirdweb-dev/js/blob/main/apps/portal/public/llms-full.txt Example of creating a wallet adapter to integrate third-party wallets with the thirdweb SDK. ```typescript import { createWalletAdapter } from "thirdweb"; const wallet = createWalletAdapter({ client, adaptedAccount, chain, onDisconnect: () => { // disconnect logic }, switchChain: async (chain) => { // switch chain logic }, }); ``` ```typescript function createWalletAdapter( options: AdapterWalletOptions, ): Wallet<"adapter">; ```