You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The thirdweb AI chat API is a standard OpenAI-compatible chat completion API that allows you to interact with the thirdweb AI model, specialized for blockchain interactions.
7
-
8
-
The thirdweb proprietary model is optimized for blockchain interactions and can:
5
+
The thirdweb AI chat API is a standard OpenAI-compatible chat completion API that allows you to interact with the thirdweb AI model, optimized for blockchain interactions.
9
6
10
7
- Query real-time data from the blockchain
11
8
- Analyze transactions
12
9
- Fetch token balances, prices and metadata
13
10
- Prepare any contract call or transaction for signing
14
-
- Prepare swaps from any token pair
11
+
- Prepare swaps from/to any token pair
15
12
- Deploy contracts
16
13
- Generate images
17
-
- Search the web for information
14
+
- Search the web
18
15
- And more!
19
16
20
-
You can use the API with the API directly, or with any OpenAI-compatible client library.
17
+
You can use the API with the HTTP API directly, or with any OpenAI-compatible client library.
publisher: "0x...", // optional, defaults to the thirdweb deployer
56
+
client,
57
+
chain,
58
+
account,
59
+
contractId: "MyPublishedContract",
60
+
contractParams: {
61
+
param1: "value1",
62
+
param2: 123,
63
+
},
64
+
publisher: "0x...", // optional, defaults to the thirdweb deployer
56
65
});
57
-
```
66
+
```
67
+
68
+
## Deploy via API
69
+
70
+
You can also deploy contracts via API by passing the contract bytecode and ABI. This will automatically verify the contract on block explorers and add it to your project dashboard.
Copy file name to clipboardExpand all lines: apps/portal/src/app/contracts/events/page.mdx
+2-21Lines changed: 2 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,7 @@ import {
3
3
TabsList,
4
4
TabsTrigger,
5
5
TabsContent,
6
+
OpenApiEndpoint,
6
7
} from"@doc";
7
8
import {
8
9
ReactIcon,
@@ -31,27 +32,7 @@ Query and listen to contract events for any deployed contract on any EVM chain.
31
32
</TabsList>
32
33
33
34
<TabsContentvalue="http">
34
-
### Get Contract Events
35
-
36
-
You can fetch contract events using the [contract events API](https://api.thirdweb.com/reference#tag/contracts/get/v1/contracts/{address}/events).
37
-
38
-
```http
39
-
GET /v1/contracts/{address}/events?chainId=<chain_id>&decode=true
40
-
Host: api.thirdweb.com
41
-
x-secret-key: <project-secret-key>
42
-
```
43
-
44
-
Authentication requires either `x-secret-key` (backend) or `x-client-id` (frontend) to be set in the request headers.
45
-
46
-
#### Parameters
47
-
48
-
-`address` - The contract address
49
-
-`chainId` - The chain ID where the contract is deployed
50
-
-`decode` - Whether to decode the event data (optional, defaults to false)
51
-
52
-
#### Response
53
-
54
-
The API returns a list of events that have been emitted by the specified contract, including event details and decoded function calls when `decode=true` is specified.
On the frontend, use your project client ID and the users's auth token to send a transaction on their behalf.
107
-
108
-
```http
109
-
POST /v1/contracts/write
110
-
Host: api.thirdweb.com
111
-
Content-Type: application/json
112
-
x-client-id: <your-project-client-id>
113
-
Authorization: Bearer <user-auth-token>
114
-
115
-
{
116
-
"from": "0x...", // the user wallet address
117
-
"chainId": "1" // the chain id
118
-
"calls": [{
119
-
"contractAddress": "0x...",
120
-
"method": "function transfer(address to, uint256 amount)",
121
-
"params": ["0x...", "1000000000000000000"],
122
-
}],
123
-
}
124
-
```
125
-
126
-
</TabsContent>
127
-
128
-
<TabsContentvalue="backend">
129
-
130
-
On the backend, use your project secret key to send a transaction from any of your server wallets.
131
-
132
-
```http
133
-
POST /v1/contracts/write
134
-
Host: api.thirdweb.com
135
-
Content-Type: application/json
136
-
x-secret-key: <your-project-secret-key>
137
-
138
-
{
139
-
"from": "0x...", // your server wallet address
140
-
"chainId": "1" // your chain id
141
-
"calls": [{
142
-
"contractAddress": "0x...",
143
-
"method": "function transfer(address to, uint256 amount)",
144
-
"params": ["0x...", "1000000000000000000"],
145
-
}],
146
-
}
147
-
```
148
-
149
-
</TabsContent>
150
-
</Tabs>
80
+
You can write multiple functions to multiple contracts on the same chain in a single request atomically, which will result in a single transaction for optimal gas efficiency.
151
81
152
-
You can batch multiple contract writes in a single request, and the transactions will be batched atomically onchain.
0 commit comments