11"use client" ;
2- import { Button } from "@/components/ui/button" ;
32import { CodeClient } from "@/components/ui/code/code.client" ;
43import { TabButtons } from "@/components/ui/tabs" ;
54import { THIRDWEB_ENGINE_CLOUD_URL } from "@/constants/env" ;
5+ import { CircleAlertIcon } from "lucide-react" ;
66import Link from "next/link" ;
77import { useState } from "react" ;
8- import type { Wallet } from "../wallet-table/types" ;
8+ import {
9+ Alert ,
10+ AlertDescription ,
11+ AlertTitle ,
12+ } from "../../../../../../../../../@/components/ui/alert" ;
913
10- export function TryItOut ( props : {
11- authToken : string ;
12- wallet ?: Wallet ;
13- team_slug : string ;
14- project_slug : string ;
15- } ) {
14+ export function TryItOut ( ) {
1615 const [ activeTab , setActiveTab ] = useState < string > ( "sdk" ) ;
1716
1817 return (
@@ -24,7 +23,8 @@ export function TryItOut(props: {
2423 Usage from your backend
2524 </ h2 >
2625 < p className = "text-muted-foreground text-sm" >
27- Send transactions from your server wallets using a simple http API
26+ Send transactions from your server wallets using the thirdweb SDK
27+ or the HTTP API directly.
2828 </ p >
2929 </ div >
3030 </ div >
@@ -33,7 +33,7 @@ export function TryItOut(props: {
3333 < TabButtons
3434 tabs = { [
3535 {
36- name : "SDK" ,
36+ name : "thirdweb SDK" ,
3737 onClick : ( ) => setActiveTab ( "sdk" ) ,
3838 isActive : activeTab === "sdk" ,
3939 } ,
@@ -68,7 +68,70 @@ export function TryItOut(props: {
6868 < div className = "h-4" />
6969
7070 { activeTab === "sdk" && (
71- < CodeClient lang = "ts" code = { sdkExample ( ) } className = "bg-background" />
71+ < div className = "flex flex-col gap-4" >
72+ < Alert variant = "info" className = "bg-background" >
73+ < CircleAlertIcon className = "size-5" />
74+ < AlertTitle > Using the thirdweb SDK on the backend</ AlertTitle >
75+ < AlertDescription className = "leading-loose" >
76+ < p className = "text-foreground text-sm" >
77+ You can use the full TypeScript thirdweb SDK in your backend,
78+ allowing you to use:{ " " }
79+ < ul className = "ml-2 list-disc py-2 pl-4" >
80+ < li >
81+ The full catalog of{ " " }
82+ < Link
83+ href = "https://portal.thirdweb.com/references/typescript/v5/functions#extensions"
84+ className = "text-blue-500"
85+ target = "_blank"
86+ >
87+ extension functions
88+ </ Link >
89+ </ li >
90+ < li >
91+ The{ " " }
92+ < Link
93+ href = "https://portal.thirdweb.com/references/typescript/v5/prepareContractCall"
94+ className = "text-blue-500"
95+ target = "_blank"
96+ >
97+ prepareContractCall
98+ </ Link > { " " }
99+ function to encode your transactions
100+ </ li >
101+ < li >
102+ The full{ " " }
103+ < Link
104+ href = "https://portal.thirdweb.com/references/typescript/v5/Account"
105+ className = "text-blue-500"
106+ target = "_blank"
107+ >
108+ account
109+ </ Link > { " " }
110+ interface, predefined chains, and more
111+ </ li >
112+ </ ul >
113+ The SDK handles encoding your transactions, signing them to
114+ Engine and polling for status.
115+ </ p >
116+ </ AlertDescription >
117+ </ Alert >
118+ < h3 className = "font-semibold text-lg tracking-tight" >
119+ Installation
120+ </ h3 >
121+ < CodeClient
122+ lang = "shell"
123+ code = { "npm install thirdweb" }
124+ className = "bg-background"
125+ />
126+ < h3 className = "font-semibold text-lg tracking-tight" >
127+ Usage example: Minting a ERC1155 NFT to a user
128+ </ h3 >
129+ < CodeClient
130+ lang = "ts"
131+ code = { sdkExample ( ) }
132+ className = "bg-background"
133+ />
134+ </ div >
72135 ) }
73136 { activeTab === "curl" && (
74137 < CodeClient
@@ -78,7 +141,25 @@ export function TryItOut(props: {
78141 />
79142 ) }
80143 { activeTab === "js" && (
81- < CodeClient lang = "js" code = { jsExample ( ) } className = "bg-background" />
144+ < div className = "flex flex-col gap-4" >
145+ < p className = "text-muted-foreground text-sm" >
146+ A lightweight, type safe wrapper package of the Engine HTTP API is
147+ available on{ " " }
148+ < Link
149+ href = "https://www.npmjs.com/package/@thirdweb-dev/engine"
150+ className = "text-blue-500"
151+ target = "_blank"
152+ >
153+ NPM
154+ </ Link >
155+ .
156+ </ p >
157+ < CodeClient
158+ lang = "js"
159+ code = { jsExample ( ) }
160+ className = "bg-background"
161+ />
162+ </ div >
82163 ) }
83164 { activeTab === "python" && (
84165 < CodeClient
@@ -97,47 +178,41 @@ export function TryItOut(props: {
97178 className = "bg-background"
98179 />
99180 ) }
100-
101- < div className = "h-4" />
102- < div className = "flex flex-row justify-end gap-4" >
103- < Button variant = { "secondary" } asChild >
104- < Link
105- href = { `/team/${ props . team_slug } /${ props . project_slug } /engine/cloud/explorer` }
106- rel = "noreferrer"
107- >
108- View API reference
109- </ Link >
110- </ Button >
111- </ div >
112181 </ div >
113182 </ div >
114183 ) ;
115184}
116185
117186const sdkExample = ( ) => `\
118- import { Engine, createThirdwebClient, sendTransaction } from "thirdweb";
119- import { claimTo } from "thirdweb/extensions/erc1155";
187+ import { createThirdwebClient, sendTransaction, getContract, Engine } from "thirdweb";
188+ import { baseSepolia } from "thirdweb/chains";
189+ import { claimTo } from "thirdweb/extensions/1155";
120190
191+ // Create a thirdweb client
121192const client = createThirdwebClient({
122193 secretKey: "<your-project-secret-key>",
123194});
124195
125196// Create a server wallet
126197const serverWallet = Engine.serverWallet({
127198 client,
128- walletAddress : "<your-server-wallet-address>",
199+ address : "<your-server-wallet-address>",
129200 vaultAccessToken: "<your-vault-access-token>",
130201});
131202
132- // Prepare a transaction
203+ // Prepare the transaction
133204const transaction = claimTo({
134- contract,
135- to: "0x...",
136- tokenId: 0n,
137- quantity: 1n,
205+ contract: getContract({
206+ client,
207+ address: "0x...", // Address of the ERC1155 token contract
208+ chain: baseSepolia, // Chain of the ERC1155 token contract
209+ }),
210+ to: "0x...", // The address of the user to mint to
211+ tokenId: 0n, // The token ID of the NFT to mint
212+ quantity: 1n, // The quantity of NFTs to mint
138213});
139214
140- // Send the transaction
215+ // Send the transaction via Engine
141216const result = await sendTransaction({
142217 account: serverWallet,
143218 transaction,
0 commit comments