### Install and Set Up thirdweb SDK in React Project
Source: https://portal.thirdweb.com/connect/wallet/overview
Guides through installing the thirdweb SDK in a React project, setting up a client instance, configuring the ThirdwebProvider, and using the ConnectButton component for wallet integration.
```bash
npm create thirdweb@latest
yarn create thirdweb
pnpm create thirdweb
bun create thirdweb
```
```typescript
import { createThirdwebClient } from "thirdweb";
// Replace this with your Client ID
const clientId = "YOUR_CLIENT_ID";
// Creates a client file (e.g., thirdwebClient.ts) for reuse throughout your app:
const client = createThirdwebClient({
clientId: clientId,
});
export { client };
```
```typescript
import React from 'react';
import ReactDOM from 'react-dom/client';
import { ThirdwebProvider } from '@thirdweb-dev/react';
import App from './App';
import { client } from './thirdwebClient'; // Import your client
const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement);
root.render(
);
```
```typescript
import { ConnectButton } from '@thirdweb-dev/react';
function MyComponent() {
return (
);
}
```
--------------------------------
### Initialize InAppWallet with Basic Configuration (TypeScript)
Source: https://portal.thirdweb.com/typescript/v5/inAppWallet
Demonstrates the basic initialization of the InAppWallet. This is the simplest way to get started.
```ts
import { inAppWallet } from "thirdweb/wallets";
const wallet = inAppWallet();
```
--------------------------------
### Create Wallet with me.rainbow
Source: https://portal.thirdweb.com/react/v5/ConnectButton
This code example illustrates the process of creating a wallet with the me.rainbow provider. It requires the thirdweb SDK to be installed and available in the project.
```javascript
import { createWallet } from "me.rainbow";
createWallet("me.rainbow");
```
--------------------------------
### Configure and Initialize In-App Wallet
Source: https://portal.thirdweb.com/typescript/v5/inAppWallet
This example demonstrates the initialization of the `inAppWallet` with specific configuration options, including `executionMode` and `mode`. This setup is crucial for defining how the wallet operates within your application.
```javascript
const wallet = inAppWallet({
executionMode: {
mode: "EIP7702"
}
})
```
--------------------------------
### Implement BuyWidget with Theming
Source: https://portal.thirdweb.com/references/typescript/v5/BuyWidgetProps
This JavaScript example demonstrates how to return a BuyWidget, passing a theme object as a configuration. This allows for dynamic styling of the widget based on the provided theme.
```javascript
function Example() {
return
```
--------------------------------
### Get Contract Data (TypeScript)
Source: https://portal.thirdweb.com/references/typescript/v5/BuyWithCryptoHistoryParams
Shows how to retrieve data from a smart contract using the Thirdweb SDK in TypeScript. This example specifically demonstrates fetching the 'count' and 'start' properties from a contract.
```typescript
import { ThirdwebClient } from "@thirdweb-dev/sdk";
import { getContract } from "@thirdweb-dev/sdk/solana";
const client = new ThirdwebClient({ clientId: "YOUR_CLIENT_ID" });
const contract = getContract("YOUR_CONTRACT_ADDRESS", "YOUR_ABI_OR_TYPE", client);
const count = await contract.call("count");
const start = await contract.call("start");
```
--------------------------------
### getInstalledModules
Source: https://portal.thirdweb.com/references/typescript/v5/isSwapRequiredPostOnramp
Gets all installed modules.
```APIDOC
## GET /references/typescript/v5/modules/getInstalledModules
### Description
Gets all installed modules.
### Method
GET
### Endpoint
/references/typescript/v5/modules/getInstalledModules
### Response
#### Success Response (200)
- **modules** (array) - An array of module addresses.
#### Response Example
```json
[
"0x...",
"0x..."
]
```
```
--------------------------------
### GET /references/typescript/v5/modules/getInstalledModules
Source: https://portal.thirdweb.com/references/typescript/v5/Theme
Retrieves the list of installed modules.
This endpoint retrieves all installed modules.
```APIDOC
## GET /references/typescript/v5/modules/getInstalledModules
### Description
Retrieves the list of installed modules. This endpoint retrieves all installed modules.
### Method
GET
### Endpoint
/references/typescript/v5/modules/getInstalledModules
### Request Example
```json
```
--------------------------------
### Initialize Thirdweb Client and Connect to Polygon
Source: https://portal.thirdweb.com/references/typescript/v5/WCConnectOptions
This snippet shows how to import necessary functions from the 'thirdweb' library, create a client instance, and connect to the Polygon network. It utilizes `createThirdwebClient` for client setup and `defineChain` to specify network details. The `await wallet.connect()` function initiates the wallet connection process.
```javascript
import { createThirdwebClient } from "thirdweb";
const client = createThirdwebClient();
await wallet.connect({ chain: polygon });
```
--------------------------------
### Create Admin and Smart Wallets (C#)
Source: https://portal.thirdweb.com/connect/account-abstraction/how-it-works
This C# snippet demonstrates creating an admin wallet using InAppWallet and Google authentication, followed by the creation of a smart wallet from the admin wallet, enabling gasless transactions.
```csharp
var adminWallet = await InAppWallet.Create(
client: thirdwebClient,
authProvider: AuthProvider.Google, // or other auth providers
);
var smartWallet = await SmartWallet.Create(adminWallet, chainId, gasless: true);
```
--------------------------------
### GET /references/typescript/v5/modules/getInstalledModules
Source: https://portal.thirdweb.com/references/typescript/v5/BuyWithFiatQuote
Retrieves the list of installed modules.
```APIDOC
## GET /references/typescript/v5/modules/getInstalledModules
### Description
Retrieves the list of installed modules.
### Method
GET
### Endpoint
/references/typescript/v5/modules/getInstalledModules
### Parameters
#### Path Parameters
- None
#### Query Parameters
- None
#### Request Body
- None
### Request Example
```json
{}
```
### Response
#### Success Response (200)
- **modules** (array) - The list of installed module addresses.
#### Response Example
```json
[
"0x
```
--------------------------------
### Example Function Definition
Source: https://portal.thirdweb.com/references/typescript/v5/useBuyWithFiatStatus
A basic function definition named 'Example'. This serves as a placeholder or starting point for more complex logic related to thirdweb LLM functionalities.
```typescript
function Example() {
```
--------------------------------
### Load Private Key from Environment Variable (Example)
Source: https://portal.thirdweb.com/references/typescript/v5/PrivateKeyToAccountOptions
Provides an example of how to load a private key from environment variables using process.env.PRIVATE_KEY. This is a recommended practice for secure key management.
```typescript
const privateKey = process.env.PRIVATE_KEY;
```
--------------------------------
### MintableERC721 API
Source: https://portal.thirdweb.com/references/typescript/v5/BuyWithCryptoTransfer
Functions for encoding installation data, generating mint signatures, getting sale configurations, installing, minting with roles or signatures, and managing MintableERC721 contracts.
```APIDOC
## POST Encode Install Data for MintableERC721
### Description
Encodes the installation data for a MintableERC721 contract.
### Method
POST
### Endpoint
/references/typescript/v5/mintableerc721/encodeInstall
### Parameters
#### Query Parameters
- **args** (object) - Required - Arguments for installation.
### Request Body
(No specific request body detailed, assuming parameters are passed via query or context)
### Response
#### Success Response (200)
- **data** (string) - Encoded installation data.
#### Response Example
```json
{
"data": "0x..."
}
```
## POST Generate Mint Signature for MintableERC721
### Description
Generates a mint signature for a MintableERC721 contract.
### Method
POST
### Endpoint
/references/typescript/v5/mintableerc721/generateMintSignature
### Parameters
#### Query Parameters
- **mintRequest** (object) - Required - Details for minting.
### Request Body
(No specific request body detailed, assuming parameters are passed via query or context)
### Response
#### Success Response (200)
- **signature** (string) - The generated mint signature.
#### Response Example
```json
{
"signature": "0x..."
}
```
## GET Sale Configuration for MintableERC721
### Description
Retrieves the sale configuration for a MintableERC721 contract.
### Method
GET
### Endpoint
/references/typescript/v5/mintableerc721/getSaleConfig
### Request Body
(No request body)
### Response
#### Success Response (200)
- **saleConfig** (object) - The sale configuration details.
#### Response Example
```json
{
"saleConfig": {
"maxClaimableSupply": "100",
"supplyClaimed": "10",
"maxTokensPerClaim": "1",
"waitInSeconds": "0",
"pricePerToken": "0",
"currency": "0x..."
}
}
```
## POST Install MintableERC721 Contract
### Description
Installs a MintableERC721 contract.
### Method
POST
### Endpoint
/references/typescript/v5/mintableerc721/install
### Parameters
#### Query Parameters
- **args** (object) - Required - Arguments for installation.
### Request Body
(No specific request body detailed, assuming parameters are passed via query or context)
### Response
#### Success Response (200)
- **transactionHash** (string) - Hash of the transaction.
#### Response Example
```json
{
"transactionHash": "0x..."
}
```
## POST Mint Tokens with Role for MintableERC721
### Description
Mints tokens with a specific role for a MintableERC721 contract.
### Method
POST
### Endpoint
/references/typescript/v5/mintableerc721/mintWithRole
### Parameters
#### Query Parameters
- **to** (string) - Required - The address to mint tokens to.
- **id** (object) - Required - Token ID details.
- **amount** (number) - Required - The amount of tokens to mint.
- **role** (string) - Optional - The role to use for minting.
- **data** (string) - Optional - Any additional data for the mint transaction.
### Request Body
(No specific request body detailed, assuming parameters are passed via query or context)
### Response
#### Success Response (200)
- **transactionHash** (string) - Hash of the transaction.
#### Response Example
```json
{
"transactionHash": "0x..."
}
```
## POST Mint Tokens with Signature for MintableERC721
### Description
Mints tokens using a signature for a MintableERC721 contract.
### Method
POST
### Endpoint
/references/typescript/v5/mintableerc721/mintWithSignature
### Parameters
#### Query Parameters
- **mintRequest** (object) - Required - Details for minting.
- **signature** (string) - Required - The mint signature.
### Request Body
(No specific request body detailed, assuming parameters are passed via query or context)
### Response
#### Success Response (200)
- **transactionHash** (string) - Hash of the transaction.
#### Response Example
```json
{
"transactionHash": "0x..."
}
```
## MintableERC721 Module
### Description
Provides access to the MintableERC721 module.
### Method
GET
### Endpoint
/references/typescript/v5/mintableerc721/module
## POST Set Sale Configuration for MintableERC721
### Description
Sets the sale configuration for a MintableERC721 contract.
### Method
POST
### Endpoint
/references/typescript/v5/mintableerc721/setSaleConfig
### Parameters
#### Query Parameters
- **saleConfig** (object) - Required - The sale configuration to set.
### Request Body
(No specific request body detailed, assuming parameters are passed via query or context)
### Response
#### Success Response (200)
- **transactionHash** (string) - Hash of the transaction.
#### Response Example
```json
{
"transactionHash": "0x..."
}
```
```
--------------------------------
### Configure thirdweb Client with Chain and Private Key (TypeScript)
Source: https://portal.thirdweb.com/references/typescript/v5/PrivateKeyToAccountOptions
This example illustrates creating a thirdweb client instance by specifying both the chain and a private key for authentication. It combines network information with secure access credentials.
```typescript
import { createThirdwebClient } from "@thirdweb-dev/sdk";
const client = createThirdwebClient({
chain: "sepolia",
privateKey: process.env.PRIVATE_KEY;
});
```
--------------------------------
### Initialize Thirdweb Client (TypeScript)
Source: https://portal.thirdweb.com/references/typescript/v5/AutoConnectProps
Demonstrates the creation of a ThirdwebClient, which serves as the entry point for the SDK. It requires either a `clientId` for client-side usage or a `secretKey` for server-side usage.
```typescript
import { createThirdwebClient } from "thirdweb";
const client = createThirdwebClient({
clientId: "",
});
```
```typescript
type client = [ThirdwebClient](/references/typescript/v5/ThirdwebClient);
```
--------------------------------
### MintableERC20 API
Source: https://portal.thirdweb.com/references/typescript/v5/BuyWithCryptoTransfer
Functions for encoding installation data, generating mint signatures, getting sale configurations, installing, minting with roles or signatures, and managing MintableERC20 contracts.
```APIDOC
## POST Encode Install Data for MintableERC20
### Description
Encodes the installation data for a MintableERC20 contract.
### Method
POST
### Endpoint
/references/typescript/v5/mintableerc20/encodeInstall
### Parameters
#### Query Parameters
- **args** (object) - Required - Arguments for installation.
### Request Body
(No specific request body detailed, assuming parameters are passed via query or context)
### Response
#### Success Response (200)
- **data** (string) - Encoded installation data.
#### Response Example
```json
{
"data": "0x..."
}
```
## POST Generate Mint Signature for MintableERC20
### Description
Generates a mint signature for a MintableERC20 contract.
### Method
POST
### Endpoint
/references/typescript/v5/mintableerc20/generateMintSignature
### Parameters
#### Query Parameters
- **mintRequest** (object) - Required - Details for minting.
### Request Body
(No specific request body detailed, assuming parameters are passed via query or context)
### Response
#### Success Response (200)
- **signature** (string) - The generated mint signature.
#### Response Example
```json
{
"signature": "0x..."
}
```
## GET Sale Configuration for MintableERC20
### Description
Retrieves the sale configuration for a MintableERC20 contract.
### Method
GET
### Endpoint
/references/typescript/v5/mintableerc20/getSaleConfig
### Request Body
(No request body)
### Response
#### Success Response (200)
- **saleConfig** (object) - The sale configuration details.
#### Response Example
```json
{
"saleConfig": {
"maxClaimableSupply": "100",
"supplyClaimed": "10",
"maxTokensPerClaim": "1",
"waitInSeconds": "0",
"pricePerToken": "0",
"currency": "0x..."
}
}
```
## POST Install MintableERC20 Contract
### Description
Installs a MintableERC20 contract.
### Method
POST
### Endpoint
/references/typescript/v5/mintableerc20/install
### Parameters
#### Query Parameters
- **args** (object) - Required - Arguments for installation.
### Request Body
(No specific request body detailed, assuming parameters are passed via query or context)
### Response
#### Success Response (200)
- **transactionHash** (string) - Hash of the transaction.
#### Response Example
```json
{
"transactionHash": "0x..."
}
```
## POST Mint Tokens with Role for MintableERC20
### Description
Mints tokens with a specific role for a MintableERC20 contract.
### Method
POST
### Endpoint
/references/typescript/v5/mintableerc20/mintWithRole
### Parameters
#### Query Parameters
- **to** (string) - Required - The address to mint tokens to.
- **amount** (number) - Required - The amount of tokens to mint.
- **role** (string) - Optional - The role to use for minting.
- **data** (string) - Optional - Any additional data for the mint transaction.
### Request Body
(No specific request body detailed, assuming parameters are passed via query or context)
### Response
#### Success Response (200)
- **transactionHash** (string) - Hash of the transaction.
#### Response Example
```json
{
"transactionHash": "0x..."
}
```
## POST Mint Tokens with Signature for MintableERC20
### Description
Mints tokens using a signature for a MintableERC20 contract.
### Method
POST
### Endpoint
/references/typescript/v5/mintableerc20/mintWithSignature
### Parameters
#### Query Parameters
- **mintRequest** (object) - Required - Details for minting.
- **signature** (string) - Required - The mint signature.
### Request Body
(No specific request body detailed, assuming parameters are passed via query or context)
### Response
#### Success Response (200)
- **transactionHash** (string) - Hash of the transaction.
#### Response Example
```json
{
"transactionHash": "0x..."
}
```
## MintableERC20 Module
### Description
Provides access to the MintableERC20 module.
### Method
GET
### Endpoint
/references/typescript/v5/mintableerc20/module
## POST Set Sale Configuration for MintableERC20
### Description
Sets the sale configuration for a MintableERC20 contract.
### Method
POST
### Endpoint
/references/typescript/v5/mintableerc20/setSaleConfig
### Parameters
#### Query Parameters
- **saleConfig** (object) - Required - The sale configuration to set.
### Request Body
(No specific request body detailed, assuming parameters are passed via query or context)
### Response
#### Success Response (200)
- **transactionHash** (string) - Hash of the transaction.
#### Response Example
```json
{
"transactionHash": "0x..."
}
```
```
--------------------------------
### Create Wallet Example (TypeScript)
Source: https://portal.thirdweb.com/references/typescript/v5/ConnectButtonProps
Demonstrates how to create a wallet using the `createWallet` function. This function likely takes a string argument specifying the wallet to create, such as 'me.rainbow' or 'io.zerion.wallet'. The output is a statement ending with a semicolon.
```typescript
createWallet("me.rainbow");
```
```typescript
createWallet("io.zerion.wallet");
```
--------------------------------
### Example GET Request with cURL
Source: https://portal.thirdweb.com/connect/wallet/overview
This snippet shows how to make a GET request to a resource using cURL, a common command-line tool for transferring data.
```APIDOC
## GET /api/example
### Description
This is a general example endpoint demonstrating a GET request.
### Method
GET
### Endpoint
/api/example
### Parameters
#### Query Parameters
- **param1** (string) - Optional - A sample query parameter.
### Request Example
```bash
curl -X GET "http://example.com/api/example?param1=value"
```
### Response
#### Success Response (200)
- **data** (object) - Contains the retrieved data.
#### Response Example
```json
{
"data": {
"key": "value"
}
}
```
```
--------------------------------
### GET /references/typescript/v5/vote/votingDelay
Source: https://portal.thirdweb.com/references/typescript/v5/BuyWithFiatQuote
Retrieves the voting delay. Specifies the delay before voting starts after proposal creation.
```APIDOC
## GET /references/typescript/v5/vote/votingDelay
### Description
Retrieves the voting delay.
### Method
GET
### Endpoint
/references/typescript/v5/vote/votingDelay
### Parameters
#### Path Parameters
- None
#### Query Parameters
- None
#### Request Body
- None
### Request Example
```json
{}
```
### Response
#### Success Response (200)
- **delay** (number) - The voting delay (in blocks).
#### Response Example
```json
{
"delay": 1
}
```
```
--------------------------------
### Initialize SDK Client
Source: https://portal.thirdweb.com/connect/wallet/overview
This snippet shows how to create a client instance to connect with thirdweb services. It's a fundamental step for interacting with the SDK.
```javascript
import { ThirdwebSDK } from "@thirdweb-dev/sdk";
// To read contract data, you can use the SDK's core client:
const sdk = new ThirdwebSDK("your-chain-name");
// To use features like the SDK's contract metadata, use the SDK's core client:
const sdk = new ThirdwebSDK("your-chain-name");
```
--------------------------------
### RoyaltyERC1155 API
Source: https://portal.thirdweb.com/references/typescript/v5/BuyWithCryptoHistoryData
Functions for encoding installation, managing default and token-specific royalty information, getting transfer validation functions and validators, installing, and managing modules for RoyaltyERC1155 contracts.
```APIDOC
## RoyaltyERC1155
### Description
Provides functionalities to manage royalty distributions for RoyaltyERC1155 contracts, including setting default and token-specific royalties.
### Endpoints
#### `encodeInstall`
##### Description
Encodes the installation data for a RoyaltyERC1155 contract.
##### Method
POST
##### Endpoint
`/references/typescript/v5/royaltyerc1155/encodeInstall`
#### `getDefaultRoyaltyInfo`
##### Description
Retrieves the default royalty information for a RoyaltyERC1155 contract.
##### Method
GET
##### Endpoint
`/references/typescript/v5/royaltyerc1155/getDefaultRoyaltyInfo`
#### `getRoyaltyInfoForToken`
##### Description
Retrieves the royalty information for a specific token in a RoyaltyERC1155 contract.
##### Method
GET
##### Endpoint
`/references/typescript/v5/royaltyerc1155/getRoyaltyInfoForToken`
#### `getTransferValidationFunction`
##### Description
Gets the transfer validation function for a RoyaltyERC1155 contract.
##### Method
GET
##### Endpoint
`/references/typescript/v5/royaltyerc1155/getTransferValidationFunction`
#### `getTransferValidator`
##### Description
Gets the transfer validator for a RoyaltyERC1155 contract.
##### Method
GET
##### Endpoint
`/references/typescript/v5/royaltyerc1155/getTransferValidator`
#### `install`
##### Description
Installs a RoyaltyERC1155 contract.
##### Method
POST
##### Endpoint
`/references/typescript/v5/royaltyerc1155/install`
#### `module`
##### Description
Gets the module for RoyaltyERC1155.
##### Method
GET
##### Endpoint
`/references/typescript/v5/royaltyerc1155/module`
#### `royaltyInfo`
##### Description
Retrieves royalty information for a RoyaltyERC1155 contract.
##### Method
GET
##### Endpoint
`/references/typescript/v5/royaltyerc1155/royaltyInfo`
#### `setDefaultRoyaltyInfo`
##### Description
Sets the default royalty information for a RoyaltyERC1155 contract.
##### Method
POST
##### Endpoint
`/references/typescript/v5/royaltyerc1155/setDefaultRoyaltyInfo`
#### `setRoyaltyInfoForToken`
##### Description
Sets the royalty information for a specific token in a RoyaltyERC1155 contract.
##### Method
POST
##### Endpoint
`/references/typescript/v5/royaltyerc1155/setRoyaltyInfoForToken`
```
--------------------------------
### Create Wallet with Coinbase (JavaScript)
Source: https://portal.thirdweb.com/references/typescript/v5/ConnectButtonProps
Demonstrates how to create a wallet instance using the Coinbase wallet provider. This function is essential for establishing a connection to a user's cryptocurrency wallet.
```javascript
createWallet("com.coinbase.wallet")
```
--------------------------------
### RoyaltyERC1155 API
Source: https://portal.thirdweb.com/references/typescript/v5/ConnectButtonProps
Includes functions for encoding installation, retrieving default and token-specific royalty information, getting transfer validation functions and validators, installing the module, and setting default or token-specific royalty information for RoyaltyERC1155.
```APIDOC
## RoyaltyERC1155
### Description
This module handles royalty information for ERC1155 tokens, allowing you to set and retrieve default and token-specific royalty details.
### Methods
* `encodeInstall()`: Encodes the installation data for the module.
* `getDefaultRoyaltyInfo()`: Retrieves the default royalty information.
* `getRoyaltyInfoForToken()`: Retrieves royalty information for a specific token.
* `getTransferValidationFunction()`: Gets the function used for transfer validation.
* `getTransferValidator()`: Retrieves the transfer validator.
* `install()`: Installs the RoyaltyERC1155 module.
* `module()`: Get the RoyaltyERC1155 module.
* `royaltyInfo()`: Retrieves royalty information.
* `setDefaultRoyaltyInfo()`: Sets the default royalty information.
* `setRoyaltyInfoForToken()`: Sets royalty information for a specific token.
```
--------------------------------
### ClaimableERC721 Module
Source: https://portal.thirdweb.com/references/typescript/v5/getBuyHistory
Functions for encoding installation data, getting claim conditions, sale configurations, and minting NFTs.
```APIDOC
## ClaimableERC721 Module Endpoints
### Description
Provides functions for managing claim conditions, sale configurations, and minting for claimable ERC721 NFTs.
### Methods
- **encodeInstall**
- **getClaimCondition**
- **getSaleConfig**
- **install**
- **mint**
- **module**
- **setClaimCondition**
- **setSaleConfig**
### Endpoints
This section details the available methods for the ClaimableERC721 module. Specific endpoint paths are not provided as these are SDK functions.
### Parameters
Parameters vary depending on the specific method called. Refer to the individual method documentation for details.
### Request Example
```json
// Example for setClaimCondition:
{
"claimCondition": {
"maxClaimableSupply": "10000",
"supplyClaimed": "0",
"maxMintableSupply": "10000",
"waitInSeconds": 0,
"pricePerToken": "0",
"currencyAddress": "0x0000000000000000000000000000000000000000"
}
}
```
### Response
#### Success Response (200)
Responses vary depending on the method. For example, `mint` might return transaction details.
#### Response Example
```json
// Example for successful mint transaction:
{
"receipt": {
"transactionHash": "0x...",
"blockNumber": 12345,
"status": 1
}
}
```
```
--------------------------------
### Initialize Thirdweb Client (JavaScript)
Source: https://portal.thirdweb.com/references/typescript/v5/BuyWithCryptoHistoryParams
Demonstrates how to initialize the Thirdweb client in JavaScript. This is a fundamental step for interacting with the Thirdweb SDK. It requires an API key for authentication.
```javascript
import { ThirdwebClient } from "@thirdweb-dev/sdk";
const client = new ThirdwebClient({
apiKey: "YOUR_API_KEY",
});
```
--------------------------------
### JavaScript Theme Configuration Example
Source: https://portal.thirdweb.com/references/typescript/v5/SwapWidgetProps
This snippet demonstrates how to define and configure themes, including setting colors for different elements. It showcases various theme names like 'darkTheme', 'customTheme', and 'lightTheme', along with specific color values.
```javascript
const darkTheme = {
colors: {
modalBg: "red"
}
});
function Example() {
return ;
}
```
--------------------------------
### RoyaltyERC1155 Module
Source: https://portal.thirdweb.com/references/typescript/v5/getBuyHistory
Methods for encoding installation, managing default and token-specific royalty information, and getting royalty validation functions.
```APIDOC
## RoyaltyERC1155 Module Endpoints
### Description
Provides functions for managing royalty information for ERC1155 tokens, including setting and retrieving default and token-specific royalties.
### Methods
- **encodeInstall**
- **getDefaultRoyaltyInfo**
- **getRoyaltyInfoForToken**
- **getTransferValidationFunction**
- **getTransferValidator**
- **install**
- **module**
- **royaltyInfo**
- **setDefaultRoyaltyInfo**
- **setRoyaltyInfoForToken**
### Endpoints
This section details the available methods for the RoyaltyERC1155 module. Specific endpoint paths are not provided as these are SDK functions.
### Parameters
Parameters vary depending on the specific method called. Refer to the individual method documentation for details.
### Request Example
```json
// Example for setDefaultRoyaltyInfo:
{
"data": {
"recipients": ["0x..."],
"bases": [50] // 50 represents 0.5%
}
}
```
### Response
#### Success Response (200)
Responses vary depending on the method. `setDefaultRoyaltyInfo` might return a transaction receipt.
#### Response Example
```json
// Example for successful transaction:
{
"receipt": {
"transactionHash": "0x...",
"blockNumber": 12345,
"status": 1
}
}
```
```
--------------------------------
### Get Fiat Purchase Status with TypeScript
Source: https://portal.thirdweb.com/references/typescript/v5/getBuyWithFiatStatus
This example demonstrates how to get the status of a fiat purchase using the `getBuyWithFiatStatus` function. It involves first obtaining a quote, opening the on-ramp provider UI, and then periodically polling for the status until the transfer is complete or a swap is required.
```typescript
// step 1 - get a quote const fiatQuote = await getBuyWithFiatQuote(fiatQuoteParams);
// step 2 - open the on-ramp provider UI window.open(quote.onRampLink, "_blank");
// step 3 - keep calling getBuyWithFiatStatus while the status is in one of the pending states const fiatStatus = await getBuyWithFiatStatus({
client,
intentId: fiatQuote.intentId,
});
// when the fiatStatus.status is "ON_RAMP_TRANSFER_COMPLETED" - the process is complete
```
--------------------------------
### ThirdwebClient Initialization
Source: https://portal.thirdweb.com/references/typescript/v5/useAutoConnect
Demonstrates how to initialize the ThirdwebClient, which is the primary entry point for interacting with the Thirdweb SDK.
```APIDOC
## POST /api/initialize
### Description
Initializes the ThirdwebClient, establishing a connection to the Thirdweb platform.
### Method
POST
### Endpoint
/api/initialize
### Parameters
#### Request Body
- **chain** (string) - Required - The blockchain network to connect to.
- **privateKey** (string) - Required - The private key for authentication.
### Request Example
```json
{
"chain": "ethereum",
"privateKey": "0x..."
}
```
### Response
#### Success Response (200)
- **client** (object) - The initialized ThirdwebClient instance.
- **address** (string) - The connected wallet address.
#### Response Example
```json
{
"client": {
"address": "0x123..."
}
}
```
```
--------------------------------
### React: Example component using ConnectButton
Source: https://portal.thirdweb.com/references/typescript/v5/ConnectButtonProps
This React component example demonstrates how to render the ConnectButton. It also shows how to conditionally pass properties like 'supportedNFTs' to the ConnectButton, allowing for customized behavior based on the connected network. The example includes a comment indicating a specific use case for displaying Pudgy Penguins on Ethereum mainnet.
```jsx
function Example() {
return (
);
}
```
--------------------------------
### Install and Configure Thirdweb SDK (Unity)
Source: https://portal.thirdweb.com/connect/wallet/overview
Integrate the Thirdweb Unity SDK by downloading the .unitypackage file and importing it into your project. Configure the ThirdwebManager prefab with your Client ID and Bundle ID.
```csharp
// 1. Download the latest thirdweb Unity SDK (.unitypackage file).
// 2. Import the package into your Unity project via Assets > Import Package > Custom Package.
// 3. Drag the ThirdwebManager prefab into your scene.
// 4. Enter your Client ID and Bundle ID from the thirdweb dashboard.
```
--------------------------------
### Get Buy With Crypto Status Example (TypeScript)
Source: https://portal.thirdweb.com/references/typescript/v5/getBuyWithCryptoStatus
This example demonstrates how to use getBuyWithCryptoStatus to check the status of a buy with crypto transaction. It first obtains a quote, handles potential approvals, sends the transaction, and then polls for the transaction status. It requires the 'thirdweb' SDK and its pay module.
```typescript
import { sendTransaction } from "thirdweb";
import { getBuyWithCryptoStatus, getBuyWithCryptoQuote } from "thirdweb/pay";
// get a quote between two tokens
const quote = await getBuyWithCryptoQuote(quoteParams);
// if approval is required, send the approval transaction
if (quote.approval) {
const txResult = await sendTransaction({
transaction: quote.approval,
account: account, // account from connected wallet
});
await waitForReceipt(txResult);
}
// send the quoted transaction
const swapTxResult = await sendTransaction({
transaction: quote.transactionRequest,
account: account, // account from connected wallet
});
await waitForReceipt(swapTxResult);
// keep polling the status of the quoted transaction until it returns a success or failure status
const status = await getBuyWithCryptoStatus({
client,
transactionHash: swapTxResult.transactionHash,
});
```
--------------------------------
### GET /llmstxt/portal_thirdweb_llms-full_txt/getBuyWithFiatHistory
Source: https://portal.thirdweb.com/references/typescript/v5/BuyWithFiatHistoryParams
Retrieves a paginated list of buy with fiat transaction history. You can filter the results by wallet address and control the number of results per page and the starting index.
```APIDOC
## GET /llmstxt/portal_thirdweb_llms-full_txt/getBuyWithFiatHistory
### Description
Retrieves a paginated list of buy with fiat transaction history. You can filter the results by wallet address and control the number of results per page and the starting index.
### Method
GET
### Endpoint
/llmstxt/portal_thirdweb_llms-full_txt/getBuyWithFiatHistory
### Parameters
#### Query Parameters
- **client** (object) - Required - The thirdweb client instance.
- **count** (number) - Optional - The number of results to return in a single page. Defaults to 10.
- **start** (number) - Optional - Index of the first result to return. Defaults to 0. If you want to start the list from nth item, you can set the start value to (n-1).
- **walletAddress** (string) - Required - The wallet address to filter the transaction history by.
### Request Example
```json
{
"client": "",
"count": 10,
"start": 0,
"walletAddress": "0x..."
}
```
### Response
#### Success Response (200)
- **transactions** (array) - An array of transaction objects.
- **transactionId** (string) - The ID of the transaction.
- **fromAddress** (string) - The address the fiat was sent from.
- **toAddress** (string) - The address the fiat was sent to.
- **amount** (object) - The amount of the transaction.
- **amount** (string) - The numeric amount.
- **currency** (string) - The currency of the amount.
- **timestamp** (string) - The timestamp of the transaction in ISO 8601 format.
#### Response Example
```json
{
"transactions": [
{
"transactionId": "txn_12345abcde",
"fromAddress": "0x123...",
"toAddress": "0x456...",
"amount": {
"amount": "100.00",
"currency": "USD"
},
"timestamp": "2023-10-27T10:00:00.000Z"
}
]
}
```
```
--------------------------------
### Bash Example: Fetching Social Auth Providers
Source: https://portal.thirdweb.com/connect/wallet/overview
This Bash command demonstrates how to fetch available social authentication providers using the thirdweb API. It requires a project secret key for authorization.
```bash
curl -X GET https://api.thirdweb.com/v1/auth/social \
-H "x-secret-key:"
```
--------------------------------
### Install Thirdweb with bun
Source: https://portal.thirdweb.com/connect/wallet/overview
Installs the Thirdweb SDK using the bun package manager. This command is suitable for projects using bun for dependency management.
```bash
bun i thirdweb
```
--------------------------------
### Initialize Thirdweb Client with ethers5Adapter (TypeScript)
Source: https://portal.thirdweb.com/references/typescript/v5/ethers5Adapter
This code demonstrates the initialization of the ThirdwebClient using the ethers5Adapter. It defines a constant `wallet` and assigns it the result of calling `ethers5Adapter`. This setup is essential for interacting with blockchain functionalities through Thirdweb within a TypeScript environment.
```typescript
const wallet = ethers5Adapter;
```
--------------------------------
### RoyaltyERC1155 Module
Source: https://portal.thirdweb.com/references/typescript/v5/BuyWithFiatHistoryData
This section details functions for the RoyaltyERC1155 contract, including encoding installation data, retrieving royalty information, getting and setting default and token-specific royalty information, and managing transfer validation functions.
```APIDOC
## RoyaltyERC1155 API
### Description
Functions for managing royalty information and transfer validation for ERC1155 tokens.
### Endpoints
- `encodeInstall`: Encode the installation data for the RoyaltyERC1155 contract.
- `getDefaultRoyaltyInfo`: Get the default royalty information for the ERC1155 contract.
- `getRoyaltyInfoForToken`: Get the royalty information for a specific ERC1155 token.
- `getTransferValidationFunction`: Get the transfer validation function for royalty enforcement.
- `getTransferValidator`: Get the transfer validator contract.
- `install`: Install the RoyaltyERC1155 contract.
- `module`: Get the RoyaltyERC1155 module.
- `royaltyInfo`: Get the royalty information for a token.
- `setDefaultRoyaltyInfo`: Set the default royalty information for the ERC1155 contract.
- `setRoyaltyInfoForToken`: Set the royalty information for a specific ERC1155 token.
```
--------------------------------
### Initialize ThirdwebClient in TypeScript
Source: https://portal.thirdweb.com/references/typescript/v5/getBuyWithFiatHistory
Demonstrates how to initialize the ThirdwebClient, which is the entry point for interacting with the Thirdweb SDK. It requires an API key and chain information.
```typescript
import { ThirdwebClient } from "@thirdweb-dev/sdk";
const client = new ThirdwebClient({
secretKey: "YOUR_SECRET_KEY", // or "YOUR_CLIENT_ID"
});
// You can also specify the chain:
const clientWithChain = new ThirdwebClient({
secretKey: "YOUR_SECRET_KEY",
chain: "ethereum", // or chain object
});
```
--------------------------------
### Wrap Application with ThirdwebProvider in React
Source: https://portal.thirdweb.com/connect/wallet/overview
This example demonstrates how to wrap your main application component ('YourApp') with the ThirdwebProvider. This setup is essential for enabling thirdweb's context and functionalities throughout your application.
```javascript
function App() {
return (
);
}
```
--------------------------------
### Get Buy with Fiat History (TypeScript)
Source: https://portal.thirdweb.com/references/typescript/v5/getBuyWithFiatHistory
Retrieves the transaction history for 'Buy with fiat' operations for a specified wallet address. This function is deprecated and requires a thirdweb client, wallet address, and pagination parameters (start and count).
```typescript
import { createThirdwebClient } from "thirdweb";
import { getBuyWithFiatHistory } from "thirdweb/pay";
const client = createThirdwebClient({ clientId: "..." });
// get the 10 latest "Buy with fiat" transactions dony by the wallet
const history = await getBuyWithFiatHistory({
client: client,
walletAddress: "0x...",
start: 0,
count: 10,
});
```
--------------------------------
### Instantiating ThirdwebSDK in JavaScript
Source: https://portal.thirdweb.com/references/typescript/v5/MediaRendererProps
This snippet shows how to create an instance of the ThirdwebSDK, likely for interacting with smart contracts or blockchain data. It requires a provider, typically from a wallet connection.
```javascript
const sdk = new ThirdwebSDK(provider);
```
--------------------------------
### Create Wallet with MetaMask Provider
Source: https://portal.thirdweb.com/references/typescript/v5/ConnectEmbedProps
This snippet shows how to use the `createWallet` function to instantiate a wallet instance, specifically configuring it for the MetaMask browser extension using the 'io.metamask' provider.
```javascript
createWallet("io.metamask")
```
--------------------------------
### Assign lightTheme to a custom theme variable in TypeScript
Source: https://portal.thirdweb.com/references/typescript/v5/ConnectButtonProps
This example demonstrates how to import and assign the `lightTheme` object from 'thirdweb/react' to a constant variable named `customTheme` in TypeScript. This allows for further customization or direct use of the theme object within your React components. This assumes the 'thirdweb/react' library is installed.
```typescript
const customTheme = lightTheme;
```
--------------------------------
### Example Usage of AutoConnect Component (React)
Source: https://portal.thirdweb.com/references/typescript/v5/AutoConnectProps
This example demonstrates how to import and use the `AutoConnect` component from 'thirdweb/react'. It shows the initialization of different wallet types (inAppWallet, metamask, coinbase, rainbow) and passing them to the `AutoConnect` component along with a client instance.
```jsx
import { AutoConnect } from "thirdweb/react";
import { createWallet, inAppWallet } from "thirdweb/wallets";
const wallets = [
inAppWallet(),
createWallet("io.metamask"),
createWallet("com.coinbase.wallet"),
createWallet("me.rainbow"),
];
function Example() {
return ;
}
```
--------------------------------
### Fetch Fiat On-Ramp Quote
Source: https://portal.thirdweb.com/references/typescript/v5/getPostOnRampQuote
This code example demonstrates how to fetch a fiat on-ramp quote using the `getBuyWithFiatQuote` function. It requires an `await` call and assumes prior setup or context for obtaining the quote. The expected return type `returnType` is detailed, including payment tokens, processing fees, and swap details.
```typescript
const returnType: {
approvalData?: QuoteApprovalInfo;
client: ThirdwebClient;
paymentTokens: Array;
processingFees: Array;
swapDetails: {
estimated: {
durationSeconds?: number;
feesUSDCents: number;
fromAmountUSDCents: number;
gasCostUSDCents?: number;
slippageBPS: number;
toAmountMinUSDCents: number;
toAmountUSDCents: number;
};
fromAddress: string;
fromAmount: string;
fromAmountWei: string;
fromToken: QuoteTokenInfo;
maxSlippageBPS: number;
toAddress: string;
toAmount: string;
toAmountMin: string;
toAmountMinWei: string;
toAmountWei: string;
toToken: QuoteTokenInfo;
};
transactionRequest: PrepareTransactionOptions;
} = await getBuyWithFiatQuote({
// Add necessary parameters here, e.g., client, fromAmount, toAmount, etc.
});
```