|
| 1 | +import { Callout, Step, Steps, Tabs, TabsContent, TabsTrigger, TabsList } from "@doc"; |
| 2 | + |
| 3 | +# Get started |
| 4 | + |
| 5 | +Learn how to get started with thirdweb Engine. This guide will walk you through the steps to start building with thirdweb Engine by creating a Vault, server wallets, and integrating into your application. |
| 6 | + |
| 7 | +## Prerequisites |
| 8 | + |
| 9 | +- Create a thirdweb project. If you don't have a project yet, [learn how to create a project](/account/api-keys/create). |
| 10 | + |
| 11 | +## Engine Setup |
| 12 | + |
| 13 | +<Steps> |
| 14 | + <Step title="Navigate to Engine"> |
| 15 | + In your project dashboard, navigate to **Engine** to get started. |
| 16 | + </Step> |
| 17 | + |
| 18 | + <Step title="Create Vault"> |
| 19 | + Create a vault to manage your Engine's server wallets. After setup, you can manage your Vault to create additional access tokens or rotate admin keys. |
| 20 | + |
| 21 | + <Callout variant="info" title="Vault"> |
| 22 | + Vault is thirdweb's key management service designed to store smart server wallets non-custodially. Learn more about [Vault]. |
| 23 | + </Callout> |
| 24 | + </Step> |
| 25 | + |
| 26 | + <Step title="Create Server Wallet"> |
| 27 | + Create a server wallet to perform blockchain actions with Engine. |
| 28 | + |
| 29 | + <Callout variant="info" title="Server Wallet"> |
| 30 | + Server wallets are smart wallets Engine uses to perform blockchain actions. [Learn more about server wallets](/engine/configure-wallets/server-wallets). |
| 31 | + </Callout> |
| 32 | + </Step> |
| 33 | + |
| 34 | + <Step title="Send Test Transaction"> |
| 35 | + To verify your server wallet setup and see how transactions work, you can send a test transaction in the next step. This sends a no-op transaction—a transaction with zero value—to your own wallet. |
| 36 | + |
| 37 | + You can send additional test transactions or proceed with the full setup whenever you're ready. |
| 38 | + </Step> |
| 39 | + |
| 40 | + <Step title="Integrate with your app"> |
| 41 | + Integrate Engine into your application using the thirdweb SDK or Engine API. [View full API reference.](https://client.scalar.com/workspace/default/request/yq_Wx56PL4Ur6jOZsAOpA) |
| 42 | + |
| 43 | + <Tabs defaultValue="curl"> |
| 44 | + <TabsList> |
| 45 | + <TabsTrigger value="curl">Curl</TabsTrigger> |
| 46 | + <TabsTrigger value="javascript">JavaScript</TabsTrigger> |
| 47 | + <TabsTrigger value="python">Python</TabsTrigger> |
| 48 | + <TabsTrigger value="go">Go</TabsTrigger> |
| 49 | + <TabsTrigger value="c-sharp">C#</TabsTrigger> |
| 50 | + </TabsList> |
| 51 | + |
| 52 | + <TabsContent value="curl"> |
| 53 | + ```bash |
| 54 | + curl -X POST "https://engine-cloud-dev-l8wt.chainsaw-dev.zeet.app/v1/write/contract" \ |
| 55 | + -H "Content-Type: application/json" \ |
| 56 | + -H "x-secret-key: <your-project-secret-key>" \ |
| 57 | + -H "x-vault-access-token: <your-vault-access-token>" \ |
| 58 | + -d '{ |
| 59 | + "executionOptions": { |
| 60 | + "from": "<your-server-wallet-address>", |
| 61 | + "chainId": "84532" |
| 62 | + }, |
| 63 | + "params": [ |
| 64 | + { |
| 65 | + "contractAddress": "0x...", |
| 66 | + "method": "function mintTo(address to, uint256 amount)", |
| 67 | + "params": ["0x...", "100"] |
| 68 | + } |
| 69 | + ] |
| 70 | + }' |
| 71 | + ``` |
| 72 | + |
| 73 | + </TabsContent> |
| 74 | + |
| 75 | + <TabsContent value="javascript"> |
| 76 | + ```typescript |
| 77 | + const response = await fetch( |
| 78 | + "https://engine-cloud-dev-l8wt.chainsaw-dev.zeet.app/v1/write/contract", |
| 79 | + { |
| 80 | + method: "POST", |
| 81 | + headers: { |
| 82 | + "Content-Type": "application/json", |
| 83 | + "x-secret-key": "<your-project-secret-key>", |
| 84 | + "x-vault-access-token": "<your-vault-access-token>", |
| 85 | + }, |
| 86 | + body: JSON.stringify({ |
| 87 | + executionOptions: { |
| 88 | + from: "<your-server-wallet-address>", |
| 89 | + chainId: "84532", |
| 90 | + }, |
| 91 | + params: [ |
| 92 | + { |
| 93 | + contractAddress: "0x...", |
| 94 | + method: "function mintTo(address to, uint256 amount)", |
| 95 | + params: ["0x...", "100"], |
| 96 | + }, |
| 97 | + ], |
| 98 | + }), |
| 99 | + } |
| 100 | + ); |
| 101 | + ``` |
| 102 | + </TabsContent> |
| 103 | + |
| 104 | + <TabsContent value="python"> |
| 105 | + ```python |
| 106 | + import requests |
| 107 | + import json |
| 108 | + |
| 109 | + url = "https://engine-cloud-dev-l8wt.chainsaw-dev.zeet.app/v1/write/contract" |
| 110 | + headers = { |
| 111 | + "Content-Type": "application/json", |
| 112 | + "x-secret-key": "<your-project-secret-key>", |
| 113 | + "x-vault-access-token": "<your-vault-access-token>" |
| 114 | + } |
| 115 | + payload = { |
| 116 | + "executionOptions": { |
| 117 | + "from": "<your-server-wallet-address>", |
| 118 | + "chainId": "84532" |
| 119 | + }, |
| 120 | + "params": [ |
| 121 | + { |
| 122 | + "contractAddress": "0x...", |
| 123 | + "method": "function mintTo(address to, uint256 amount)", |
| 124 | + "params": ["0x...", "100"] |
| 125 | + } |
| 126 | + ] |
| 127 | + } |
| 128 | + |
| 129 | + response = requests.post(url, headers=headers, json=payload) |
| 130 | + result = response.json() |
| 131 | + ``` |
| 132 | + </TabsContent> |
| 133 | + |
| 134 | + <TabsContent value="go"> |
| 135 | + ```go |
| 136 | + package main |
| 137 | + |
| 138 | + import ( |
| 139 | + "bytes" |
| 140 | + "encoding/json" |
| 141 | + "fmt" |
| 142 | + "net/http" |
| 143 | + ) |
| 144 | + |
| 145 | + func main() { |
| 146 | + url := "https://engine-cloud-dev-l8wt.chainsaw-dev.zeet.app/v1/write/contract" |
| 147 | + |
| 148 | + // Create the request payload |
| 149 | + type Param struct { |
| 150 | + ContractAddress string `json:"contractAddress"` |
| 151 | + Method string `json:"method"` |
| 152 | + Params []string `json:"params"` |
| 153 | + } |
| 154 | + |
| 155 | + type RequestBody struct { |
| 156 | + ExecutionOptions struct { |
| 157 | + From string `json:"from"` |
| 158 | + ChainId string `json:"chainId"` |
| 159 | + } `json:"executionOptions"` |
| 160 | + Params []Param `json:"params"` |
| 161 | + } |
| 162 | + |
| 163 | + requestBody := RequestBody{ |
| 164 | + Params: []Param{ |
| 165 | + { |
| 166 | + ContractAddress: "0x...", |
| 167 | + Method: "function mintTo(address to, uint256 amount)", |
| 168 | + Params: []string{"0x...", "100"}, |
| 169 | + }, |
| 170 | + }, |
| 171 | + } |
| 172 | + requestBody.ExecutionOptions.From = "<your-server-wallet-address>" |
| 173 | + requestBody.ExecutionOptions.ChainId = "84532" |
| 174 | + |
| 175 | + jsonData, _ := json.Marshal(requestBody) |
| 176 | + |
| 177 | + // Create the HTTP request |
| 178 | + req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData)) |
| 179 | + req.Header.Set("Content-Type", "application/json") |
| 180 | + req.Header.Set("x-secret-key", "<your-project-secret-key>") |
| 181 | + req.Header.Set("x-vault-access-token", "<your-vault-access-token>") |
| 182 | + |
| 183 | + // Send the request |
| 184 | + client := &http.Client{} |
| 185 | + resp, err := client.Do(req) |
| 186 | + if err != nil { |
| 187 | + fmt.Println("Error:", err) |
| 188 | + return |
| 189 | + } |
| 190 | + defer resp.Body.Close() |
| 191 | + |
| 192 | + // Process the response |
| 193 | + var result map[string]interface{} |
| 194 | + json.NewDecoder(resp.Body).Decode(&result) |
| 195 | + fmt.Println("Response:", result) |
| 196 | + } |
| 197 | + ``` |
| 198 | + </TabsContent> |
| 199 | + |
| 200 | + <TabsContent value="c-sharp"> |
| 201 | + ``` |
| 202 | + using System; |
| 203 | + using System.Net.Http; |
| 204 | + using System.Text; |
| 205 | + using System.Text.Json; |
| 206 | + using System.Threading.Tasks; |
| 207 | +
|
| 208 | + class Program |
| 209 | + { |
| 210 | + static async Task Main() |
| 211 | + { |
| 212 | + var url = "https://engine-cloud-dev-l8wt.chainsaw-dev.zeet.app/v1/write/contract"; |
| 213 | + |
| 214 | + var requestData = new |
| 215 | + { |
| 216 | + executionOptions = new |
| 217 | + { |
| 218 | + from = "<your-server-wallet-address>", |
| 219 | + chainId = "84532" |
| 220 | + }, |
| 221 | + @params = new[] |
| 222 | + { |
| 223 | + new |
| 224 | + { |
| 225 | + contractAddress = "0x...", |
| 226 | + method = "function mintTo(address to, uint256 amount)", |
| 227 | + @params = new[] { "0x...", "100" } |
| 228 | + } |
| 229 | + } |
| 230 | + }; |
| 231 | + |
| 232 | + var json = JsonSerializer.Serialize(requestData); |
| 233 | + var content = new StringContent(json, Encoding.UTF8, "application/json"); |
| 234 | + |
| 235 | + using var httpClient = new HttpClient(); |
| 236 | + httpClient.DefaultRequestHeaders.Add("x-secret-key", "<your-project-secret-key>"); |
| 237 | + httpClient.DefaultRequestHeaders.Add("x-vault-access-token", "<your-vault-access-token>"); |
| 238 | + |
| 239 | + var response = await httpClient.PostAsync(url, content); |
| 240 | + var responseContent = await response.Content.ReadAsStringAsync(); |
| 241 | + |
| 242 | + Console.WriteLine(responseContent); |
| 243 | + } |
| 244 | +} |
| 245 | + ``` |
| 246 | + </TabsContent> |
| 247 | + </Tabs> |
| 248 | + |
| 249 | + <Callout variant="info" title="TypeScript SDK"> |
| 250 | + You can use the full TypeScript SDK in your backend, allowing you to use: |
| 251 | + - The full catalog of extension functions |
| 252 | + - The prepareContractCall function to encode your transactions |
| 253 | + - The full account interface, predefined chains, and more |
| 254 | + The SDK handles encoding your transactions, signing them to Engine and polling for status. |
| 255 | + </Callout> |
| 256 | + </Step> |
| 257 | +</Steps> |
| 258 | + |
0 commit comments