Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/playground-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"next": "15.3.5",
"next-themes": "^0.4.6",
"nextjs-toploader": "^1.6.12",
"openapi-types": "^12.1.3",
"openapi-types": "12.1.3",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Pinning openapi-types is fine; verify if it should be a devDependency and align versions workspace-wide.

If openapi-types is only used for TypeScript types, prefer moving it to devDependencies to keep production/runtime deps lean. Also ensure all packages pin the same version to avoid duplication.

Run this script to (a) find all imports/usages of openapi-types and (b) report every package.json that declares it and where (dependencies vs devDependencies):


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Usages of 'openapi-types' across the repo =="
rg -n --hidden --no-ignore -g '!**/node_modules/**' -e "from ['\"]openapi-types['\"]|require\(['\"]openapi-types['\"]\)" || true

echo
echo "== package.json declarations of 'openapi-types' =="
fd -H -t f package.json | while read -r f; do
  dep_ver=$(jq -r '.dependencies["openapi-types"] // empty' "$f")
  dev_ver=$(jq -r '.devDependencies["openapi-types"] // empty' "$f")
  if [[ -n "$dep_ver" || -n "$dev_ver" ]]; then
    echo "$f"
    if [[ -n "$dep_ver" ]]; then echo "  dependencies: $dep_ver"; fi
    if [[ -n "$dev_ver" ]]; then echo "  devDependencies: $dev_ver"; fi
  fi
done

Length of output: 4572


Move openapi-types to devDependencies and align versions

All imports of openapi-types in the repo are type‐only (import type { OpenAPIV3[_1] }…), so it does not need to ship at runtime. Currently it’s declared in dependencies in two spots:

• apps/playground-web/package.json (v12.1.3)
• apps/portal/package.json (v12.1.3)

Please:

  • Remove "openapi-types": "12.1.3" from dependencies in both package.json files
  • Add "openapi-types": "12.1.3" under devDependencies in both
  • Confirm no other packages declare it (all should use v12.1.3)
🤖 Prompt for AI Agents
In apps/playground-web/package.json (around line 25) and
apps/portal/package.json (search for the same dependency), move "openapi-types":
"12.1.3" out of "dependencies" and add it under "devDependencies" with the same
version string; remove the entry from dependencies in both files, add it to
devDependencies in both, and run a quick repo-wide search to confirm no other
package.json declares "openapi-types" at a different version (update any found
to 12.1.3 or remove if unnecessary).

"posthog-js": "1.256.1",
"prettier": "3.6.2",
"react": "19.1.0",
Expand Down
1 change: 1 addition & 0 deletions apps/portal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"nextjs-toploader": "^1.6.12",
"node-html-markdown": "^1.3.0",
"node-html-parser": "^6.1.13",
"openapi-types": "12.1.3",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Confirm openapi-types needs to be a runtime dependency; otherwise move to devDependencies.

If only used for typing, keep it in devDependencies to avoid bloating prod lockfiles and potential client bundles.

Run the same verification script from the playground package review or this package-local check:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Usages of 'openapi-types' in portal =="
rg -n --hidden --no-ignore -g 'apps/portal/**' -e "from ['\"]openapi-types['\"]|require\(['\"]openapi-types['\"]\)" || true

echo
echo "== portal/package.json declaration =="
jq '{dependencies: .dependencies["openapi-types"], devDependencies: .devDependencies["openapi-types"]}' apps/portal/package.json

Length of output: 650


Move openapi-types to devDependencies

openapi-types is only imported as a TypeScript type in apps/portal/src/components/Document/APIEndpointMeta/OpenApiEndpoint.tsx and isn’t used at runtime. Keeping it in dependencies bloats production installs and client bundles.

Please update apps/portal/package.json:

• Remove from dependencies
• Add under devDependencies

Example diff:

--- apps/portal/package.json
@@ dependencies:
-   "openapi-types": "12.1.3",
@@ devDependencies:
+  "openapi-types": "12.1.3",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"openapi-types": "12.1.3",
--- apps/portal/package.json
@@ "dependencies": {
- "openapi-types": "12.1.3",
@@ "devDependencies": {
+ "openapi-types": "12.1.3",
🤖 Prompt for AI Agents
In apps/portal/package.json around line 27, move "openapi-types": "12.1.3" out
of dependencies and add the same entry under devDependencies; remove the
key/value from the dependencies object, insert it into devDependencies, then run
your package manager (npm/yarn/pnpm) to update lockfiles so production installs
no longer include this type-only package.

"posthog-js": "1.256.1",
"prettier": "3.6.2",
"react": "19.1.0",
Expand Down
91 changes: 0 additions & 91 deletions apps/portal/src/app/ai/chat/EndpointMetadata.tsx

This file was deleted.

22 changes: 12 additions & 10 deletions apps/portal/src/app/ai/chat/page.mdx
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
import { EndpointMetadata } from "./EndpointMetadata";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@doc";
import { Tabs, TabsContent, TabsList, TabsTrigger, OpenApiEndpoint } from "@doc";

# Chat API

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.

The thirdweb proprietary model is optimized for blockchain interactions and can:
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.

- Query real-time data from the blockchain
- Analyze transactions
- Fetch token balances, prices and metadata
- Prepare any contract call or transaction for signing
- Prepare swaps from any token pair
- Prepare swaps from/to any token pair
- Deploy contracts
- Generate images
- Search the web for information
- Search the web
- And more!

You can use the API with the API directly, or with any OpenAI-compatible client library.
You can use the API with the HTTP API directly, or with any OpenAI-compatible client library.

<Tabs defaultValue="api">
<TabsList>
<TabsTrigger value="api">HTTP API</TabsTrigger>
<TabsTrigger value="openai">OpenAI Client</TabsTrigger>
</TabsList>
<TabsContent value="api">
<EndpointMetadata />
<OpenApiEndpoint path="/ai/chat" method="POST" specUrl="https://api.thirdweb-dev.com/openapi.json" />
</TabsContent>
<TabsContent value="openai">

Expand All @@ -50,4 +47,9 @@ chat_completion = client.chat.completions.create(
print(chat_completion)
```
</TabsContent>
</Tabs>
</Tabs>

### Going further

- [Handle streaming responses](/ai/chat/streaming)
- [Full API Reference](https://api.thirdweb-dev.com/reference#tag/ai/post/ai/chat)
4 changes: 2 additions & 2 deletions apps/portal/src/app/ai/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export const sidebar: SideBar = {
icon: <ZapIcon />,
},
{
name: "Response Handling",
href: "/ai/chat/handling-responses",
name: "Streaming Responses",
href: "/ai/chat/streaming",
},
Comment on lines +16 to 18
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Rename to “Streaming Responses” looks good; verify route exists and unify API reference domain.

  • Ensure /ai/chat/streaming page exists to avoid dead links.
  • The API Reference link below uses api.thirdweb-dev.com while other pages in this PR use api.thirdweb.com. Consider switching to the canonical domain or centralizing as a constant.

Script to check the page exists and to find any lingering api.thirdweb-dev.com references:

Apply this diff to normalize the API Reference domain in this file:

-          href: "https://api.thirdweb-dev.com/reference#tag/ai/post/ai/chat",
+          href: "https://api.thirdweb.com/reference#tag/ai/post/ai/chat",

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Verify streaming page exists (any of TSX/MDX)
if test -d "apps/portal/src/app/ai/chat/streaming"; then
  fd -t f . apps/portal/src/app/ai/chat/streaming
else
  echo "Missing: apps/portal/src/app/ai/chat/streaming"
  exit 1
fi

# Find dev-domain API references across repo
echo
echo "Occurrences of api.thirdweb-dev.com/reference:"
rg -n --hidden --no-ignore -e "api\.thirdweb-dev\.com/reference" || true

Length of output: 581


Confirm /ai/chat/streaming route exists and normalize API Reference domain

  • Verified that apps/portal/src/app/ai/chat/streaming/page.mdx implements the /ai/chat/streaming route.
  • Update all remaining api.thirdweb-dev.com references to the canonical api.thirdweb.com:

• apps/portal/src/app/ai/sidebar.tsx (around line 21):

-          href: "https://api.thirdweb-dev.com/reference#tag/ai/post/ai/chat",
+          href: "https://api.thirdweb.com/reference#tag/ai/post/ai/chat",

• apps/portal/src/app/ai/chat/page.mdx (around line 55):

- [Full API Reference](https://api.thirdweb-dev.com/reference#tag/ai/post/ai/chat)
+ [Full API Reference](https://api.thirdweb.com/reference#tag/ai/post/ai/chat)

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In apps/portal/src/app/ai/sidebar.tsx around lines 16 to 18, the sidebar link
points to /ai/chat/streaming (confirming the route exists is already done) and
you must also normalize the API domain across the project: replace any remaining
occurrences of api.thirdweb-dev.com with api.thirdweb.com (specifically update
apps/portal/src/app/ai/sidebar.tsx near line 21 and
apps/portal/src/app/ai/chat/page.mdx near line 55) so all references use the
canonical api.thirdweb.com domain.

{
name: "API Reference",
Expand Down
63 changes: 42 additions & 21 deletions apps/portal/src/app/contracts/deploy/page.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
import { OpenApiEndpoint, createMetadata } from "@doc";

export const metadata = createMetadata({
image: {
title: "Deploy contracts",
icon: "contracts",
},
title: "Deploy Contracts",
description: "Deploy contracts on any EVM chain.",
});

# Deploy Contracts

You can deploy contracts via CLI or programatically.
Expand All @@ -16,8 +27,6 @@ You can also publish your contract to be deployable by anyone on any chain.
npx thirdweb publish -k <project-secret-key>
```



## Deploying via SDK

You can deploy contracts from ABI and bytecode.
Expand All @@ -26,15 +35,15 @@ You can deploy contracts from ABI and bytecode.
import { deployContract } from "thirdweb/deploys";

const address = await deployContract({
client,
chain,
bytecode: "0x...",
abi: contractAbi,
constructorParams: {
param1: "value1",
param2: 123,
},
salt, // optional: salt enables deterministic deploys
client,
chain,
bytecode: "0x...",
abi: contractAbi,
constructorParams: {
param1: "value1",
param2: 123,
},
salt, // optional: salt enables deterministic deploys
});
```

Expand All @@ -44,14 +53,26 @@ Or alternatively, you can deploy a contract from a previously published contract
import { deployPublishedContract } from "thirdweb/deploys";

const address = await deployPublishedContract({
client,
chain,
account,
contractId: "MyPublishedContract",
contractParams: {
param1: "value1",
param2: 123,
},
publisher: "0x...", // optional, defaults to the thirdweb deployer
client,
chain,
account,
contractId: "MyPublishedContract",
contractParams: {
param1: "value1",
param2: 123,
},
publisher: "0x...", // optional, defaults to the thirdweb deployer
});
```
```

## Deploy via API

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.

<OpenApiEndpoint path="/v1/contracts" method="POST" />

## List all deployed contracts

You can list all deployed contracts for your project.

<OpenApiEndpoint path="/v1/contracts" method="GET" />
23 changes: 2 additions & 21 deletions apps/portal/src/app/contracts/events/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
TabsList,
TabsTrigger,
TabsContent,
OpenApiEndpoint,
} from "@doc";
import {
ReactIcon,
Expand Down Expand Up @@ -31,27 +32,7 @@ Query and listen to contract events for any deployed contract on any EVM chain.
</TabsList>

<TabsContent value="http">
### Get Contract Events

You can fetch contract events using the [contract events API](https://api.thirdweb.com/reference#tag/contracts/get/v1/contracts/{address}/events).

```http
GET /v1/contracts/{address}/events?chainId=<chain_id>&decode=true
Host: api.thirdweb.com
x-secret-key: <project-secret-key>
```

Authentication requires either `x-secret-key` (backend) or `x-client-id` (frontend) to be set in the request headers.

#### Parameters

- `address` - The contract address
- `chainId` - The chain ID where the contract is deployed
- `decode` - Whether to decode the event data (optional, defaults to false)

#### Response

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.
<OpenApiEndpoint path="/v1/contracts/{chainId}/{address}/events" method="GET" />

</TabsContent>

Expand Down
84 changes: 7 additions & 77 deletions apps/portal/src/app/contracts/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
TabsList,
TabsTrigger,
TabsContent,
OpenApiEndpoint,
} from "@doc";
import {
ReactIcon,
Expand Down Expand Up @@ -67,89 +68,18 @@ Read, write, and deploy smart contracts on any EVM compatible blockchain.
</TabsList>

<TabsContent value="http">
### Read a Contract

You can read contract data efficiently using the [contract read API](https://api.thirdweb.com/reference#tag/contracts/post/v1/contracts/read).

```http
GET /v1/contracts/read
Host: api.thirdweb.com
Content-Type: application/json
x-client-id: <your-project-client-id>

{
"chainId": "1" // your chain id
"calls": [{
"contractAddress": "0x...",
"method": "function allowance(address owner, address spender)",
"params": ["0x...", "0x..."],
}],
}
```

You can batch multiple contract reads in a single request, and the response will be an array of results or errors.
### Read from Contracts

Authentication requires either `x-secret-key` (backend) or `x-client-id` (frontend) to be set in the request headers.
You can efficiently read data from multiple functions or contracts in a single request.

### Write to a Contract
<OpenApiEndpoint path="/v1/contracts/read" method="POST" />

You can write to a contract using the [contract write API](https://api.thirdweb.com/reference#tag/contracts/post/v1/contracts/write).

<Tabs defaultValue="frontend">
<TabsList>
<TabsTrigger value="frontend">Frontend</TabsTrigger>
<TabsTrigger value="backend">Backend</TabsTrigger>
</TabsList>

<TabsContent value="frontend">
### Write to Contracts

On the frontend, use your project client ID and the users's auth token to send a transaction on their behalf.

```http
POST /v1/contracts/write
Host: api.thirdweb.com
Content-Type: application/json
x-client-id: <your-project-client-id>
Authorization: Bearer <user-auth-token>

{
"from": "0x...", // the user wallet address
"chainId": "1" // the chain id
"calls": [{
"contractAddress": "0x...",
"method": "function transfer(address to, uint256 amount)",
"params": ["0x...", "1000000000000000000"],
}],
}
```

</TabsContent>

<TabsContent value="backend">

On the backend, use your project secret key to send a transaction from any of your server wallets.

```http
POST /v1/contracts/write
Host: api.thirdweb.com
Content-Type: application/json
x-secret-key: <your-project-secret-key>

{
"from": "0x...", // your server wallet address
"chainId": "1" // your chain id
"calls": [{
"contractAddress": "0x...",
"method": "function transfer(address to, uint256 amount)",
"params": ["0x...", "1000000000000000000"],
}],
}
```

</TabsContent>
</Tabs>
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.

You can batch multiple contract writes in a single request, and the transactions will be batched atomically onchain.
<OpenApiEndpoint path="/v1/contracts/write" method="POST" />

</TabsContent>

Expand Down
Loading
Loading