Skip to content

Commit 625287c

Browse files
[Docs] Update API endpoints and add frontend/backend examples
1 parent cf22c23 commit 625287c

File tree

28 files changed

+873
-245
lines changed

28 files changed

+873
-245
lines changed

apps/portal/src/app/Header.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ export const connectLinks: Array<{
119119
] as const;
120120

121121
const apisLinks = [
122+
{
123+
href: "https://api.thirdweb.com/reference",
124+
name: "HTTP API",
125+
},
122126
{
123127
href: "https://insight.thirdweb.com/reference",
124128
name: "Insight",
@@ -281,6 +285,22 @@ export function Header() {
281285
</nav>
282286

283287
<div className="flex items-center gap-3">
288+
<div className="px-1">
289+
<DropdownLinks
290+
category="AI"
291+
links={[
292+
{
293+
href: "/ai/mcp",
294+
name: "MCP",
295+
},
296+
{
297+
href: "/ai/llms-txt",
298+
name: "LLMs.txt",
299+
},
300+
]}
301+
onLinkClick={() => setShowBurgerMenu(false)}
302+
/>
303+
</div>
284304
<div className="px-1">
285305
<DropdownLinks
286306
category="SDKs"

apps/portal/src/app/ai/layout.tsx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { createMetadata } from "@doc";
2+
import { BookIcon, ZapIcon } from "lucide-react";
3+
import { DocLayout } from "@/components/Layouts/DocLayout";
4+
5+
export default async function Layout(props: { children: React.ReactNode }) {
6+
return (
7+
<DocLayout
8+
editPageButton={true}
9+
sideBar={{
10+
links: [
11+
{
12+
name: "MCP Server",
13+
icon: <ZapIcon />,
14+
href: "/ai/mcp",
15+
},
16+
{
17+
name: "llms.txt",
18+
icon: <BookIcon />,
19+
href: "/ai/llm-txt",
20+
},
21+
],
22+
name: "AI",
23+
}}
24+
>
25+
<div>{props.children}</div>
26+
</DocLayout>
27+
);
28+
}
29+
30+
export const metadata = createMetadata({
31+
description: "AI tools for agents and LLM clients.",
32+
title: "thirdweb AI",
33+
});
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# llms.txt
2+
3+
Use these llms.txt files to instruct your LLM on how to use the thirdweb API.
4+
5+
### thirdweb API reference
6+
7+
The [thirdweb HTTP API reference](https://api.thirdweb.com/reference) as markdown.
8+
9+
Available at: https://api.thirdweb.com/llms.txt
10+
11+
### Typescript SDK quick reference
12+
13+
Contains a table of contents for the thirdweb Typescript SDK documentation.
14+
15+
Available at: https://portal.thirdweb.com/llms.txt
16+
17+
### Typescript SDK full documentation
18+
19+
Contains the entire thirdweb Typescript SDK documentation as markdown. Requires large context windows.
20+
21+
Available at: https://portal.thirdweb.com/llms-full.txt
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# MCP server
2+
3+
You can use the thirdweb MCP server to interact with the thirdweb API from your agents or LLM client.
4+
5+
### Remote MCP endpoint
6+
7+
You can access the MCP server at the following url, with your project secret key.
8+
9+
```http
10+
# endpoint
11+
POST https://api.thirdweb.com/mcp
12+
13+
# auth header (required)
14+
x-secret-key <your-project-secret-key>
15+
```
16+
17+
### Usage with agents
18+
19+
Use your favorite agent framework to plug in the MCP server as a collection of tools for your agent. Refer to your agent framework's documentation for more information.
20+
21+
#### Example usage with langchain:
22+
23+
```python
24+
from langchain_mcp_adapters.client import MultiServerMCPClient
25+
from langgraph.prebuilt import create_react_agent
26+
27+
client = MultiServerMCPClient(
28+
{
29+
"thirdweb-api": {
30+
"transport": "streamable_http",
31+
"url": "https://api.thirdweb-dev.com/mcp",
32+
"headers": {
33+
"x-secret-key": "<your-project-secret-key>"
34+
},
35+
}
36+
}
37+
)
38+
tools = await client.get_tools()
39+
agent = create_react_agent("openai:gpt-4.1", tools)
40+
response = await agent.ainvoke({"messages": "create a server wallet called 'my-wallet'"})
41+
```
42+
43+
### Usage with LLM clients
44+
45+
You can also use the MCP server on your own LLM client, like cursor, claude code and more. Refer to your LLM client's documentation for more information.
46+
47+
#### Example usage with Cursor:
48+
49+
Add the following to your `.cursor/mcp.json` file:
50+
51+
```json
52+
{
53+
"mcpServers": {
54+
"thirdweb-api": {
55+
"url": "https://api.thirdweb-dev.com/mcp",
56+
"headers": {
57+
"x-secret-key": "<your-project-secret-key>"
58+
}
59+
}
60+
}
61+
}
62+
```

apps/portal/src/app/contracts/page.mdx

Lines changed: 59 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ export const metadata = createMetadata({
3434

3535
Read, write, and deploy smart contracts on any EVM compatible blockchain.
3636

37-
---
38-
3937
<Tabs defaultValue="http">
4038
<TabsList>
4139
<TabsTrigger value="http" className="flex items-center gap-2 [&>p]:mb-0">
@@ -71,19 +69,16 @@ Read, write, and deploy smart contracts on any EVM compatible blockchain.
7169
<TabsContent value="http">
7270
### Read a Contract
7371

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

7674
```http
77-
GET /v1/contract/read
75+
GET https://api.thirdweb.com/v1/contracts/read
7876
Content-Type: application/json
79-
x-secret-key: <your-project-secret-key>
77+
x-client-id: <your-project-client-id>
8078
8179
{
82-
"readOptions": {
83-
"chainId": "1" // your chain id
84-
"from": "0x...", // optional, if you want to read from a specific address
85-
},
86-
"params": [{
80+
"chainId": "1" // your chain id
81+
"calls": [{
8782
"contractAddress": "0x...",
8883
"method": "function allowance(address owner, address spender)",
8984
"params": ["0x...", "0x..."],
@@ -93,33 +88,65 @@ Read, write, and deploy smart contracts on any EVM compatible blockchain.
9388

9489
You can batch multiple contract reads in a single request, and the response will be an array of results or errors.
9590

91+
Authentication requires either `x-secret-key` (backend) or `x-client-id` (frontend) to be set in the request headers.
92+
9693
### Write to a Contract
9794

98-
You can write to a contract using the [contract write API](https://engine.thirdweb.com/reference).
99-
100-
```http
101-
POST /v1/contract/write
102-
Content-Type: application/json
103-
x-secret-key: <your-project-secret-key>
104-
105-
{
106-
"executionOptions": {
107-
"from": "0x...", // your server wallet address
108-
"chainId": "1" // your chain id
109-
},
110-
"params": [{
111-
"contractAddress": "0x...",
112-
"method": "function transfer(address to, uint256 amount)",
113-
"params": ["0x...", "1000000000000000000"],
114-
}]
115-
}
116-
```
95+
You can write to a contract using the [contract write API](https://api.thirdweb.com/reference#tag/contracts/post/v1/contracts/write).
11796

118-
You can batch multiple contract writes in a single request, and the transactions will be batched atomically onchain.
97+
<Tabs defaultValue="frontend">
98+
<TabsList>
99+
<TabsTrigger value="frontend">Frontend</TabsTrigger>
100+
<TabsTrigger value="backend">Backend</TabsTrigger>
101+
</TabsList>
119102

120-
### Deploy a Contract
103+
<TabsContent value="frontend">
104+
105+
On the frontend, use your project client ID and the users's auth token to send a transaction on their behalf.
106+
107+
```http
108+
POST https://api.thirdweb.com/v1/contracts/write
109+
Content-Type: application/json
110+
x-client-id: <your-project-client-id>
111+
Authorization: Bearer <user-auth-token>
112+
113+
{
114+
"from": "0x...", // the user wallet address
115+
"chainId": "1" // the chain id
116+
"calls": [{
117+
"contractAddress": "0x...",
118+
"method": "function transfer(address to, uint256 amount)",
119+
"params": ["0x...", "1000000000000000000"],
120+
}],
121+
}
122+
```
123+
124+
</TabsContent>
121125

122-
You can deploy a contract using the [contract deploy API](https://engine.thirdweb.com/reference).
126+
<TabsContent value="backend">
127+
128+
On the backend, use your project secret key to send a transaction from any of your server wallets.
129+
130+
```http
131+
POST https://api.thirdweb.com/v1/contracts/write
132+
Content-Type: application/json
133+
x-secret-key: <your-project-secret-key>
134+
135+
{
136+
"from": "0x...", // your server wallet address
137+
"chainId": "1" // your chain id
138+
"calls": [{
139+
"contractAddress": "0x...",
140+
"method": "function transfer(address to, uint256 amount)",
141+
"params": ["0x...", "1000000000000000000"],
142+
}],
143+
}
144+
```
145+
146+
</TabsContent>
147+
</Tabs>
148+
149+
You can batch multiple contract writes in a single request, and the transactions will be batched atomically onchain.
123150

124151
</TabsContent>
125152

apps/portal/src/app/contracts/sidebar.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ZapIcon } from "lucide-react";
1+
import { ExternalLinkIcon, ZapIcon } from "lucide-react";
22
import type { SideBar } from "@/components/Layouts/DocLayout";
33
import {
44
DotNetIcon,
@@ -18,6 +18,11 @@ export const sidebar: SideBar = {
1818
name: "Get Started",
1919
icon: <ZapIcon />,
2020
},
21+
{
22+
href: "https://playground.thirdweb.com/",
23+
icon: <ExternalLinkIcon />,
24+
name: "Playground",
25+
},
2126
{ separator: true },
2227
{
2328
isCollapsible: false,

apps/portal/src/app/page.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ function ReferenceSection() {
112112
<section>
113113
<SectionTitle anchorId="backend" title="Backend APIs" />
114114
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-3">
115+
<SDKCard
116+
href="https://api.thirdweb.com/reference"
117+
icon={ConnectIcon}
118+
title="HTTP API"
119+
/>
115120
<SDKCard
116121
href="https://engine.thirdweb.com/reference"
117122
icon={EngineIcon}
@@ -127,11 +132,6 @@ function ReferenceSection() {
127132
icon={BridgeIcon}
128133
title="Payments"
129134
/>
130-
<SDKCard
131-
href="/wallets/get-users"
132-
icon={ConnectIcon} // TODO: actual openAPI docs
133-
title="Wallets"
134-
/>
135135
<SDKCard
136136
href="/bundler"
137137
icon={ConnectIcon} // TODO: actual openAPI docs
569 KB
Loading
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import {DocImage} from "@doc";
2+
import FeeShare from './assets/fee-dash.png';
3+
4+
5+
# Understanding fees
6+
7+
Understand how protocol, developer, and onramp fees work with Payments.
8+
9+
### Developer Fee
10+
11+
To monetize applications or games, you are able to set a developer fee on each crypto-to-crypto or swap transaction. You may set this percentage
12+
through Project > Payments > Settings.
13+
14+
<DocImage src={FeeShare} alt="Developer fee share" />
15+
16+
### Protocol Fee
17+
18+
Our protocol fee is a flat 30 basis points (0.30%) applied on the source token amount.
19+
This fee is independent of network gas fees and does not fluctuate.
20+
21+
#### Setting fees using buy or sell
22+
23+
You can configure who pays the protocol fee for buy or sell transactions by specifying the input amount `sell` or `buy`.
24+
25+
See full reference for [`buy`](https://portal.thirdweb.com/references/typescript/v5/buy/prepare) and [`sell`](https://portal.thirdweb.com/references/typescript/v5/sell/prepare).
26+
27+
#### Setting fees on transfers or purchase mode
28+
29+
You can configure who pays the protocol fee for transfers or purchase mode using the `feePayer` setting. This affects the
30+
total amount paid by the user and the amount received by the destination (e.g., a seller, app, or partner).
31+
32+
feePayer=buyer (Default) i.e. the user covers the protocol fee.
33+
34+
Example: If the source token is 10 USDC, the user pays 10.30 USDC.
35+
36+
- thirdweb receives: 0.30 USDC
37+
38+
- Receiver receives: 10.00 USDC
39+
40+
feePayer=receiver i.e. the receiver covers the protocol fee.
41+
42+
Example: The user pays 10.00 USDC.
43+
44+
- thirdweb receives: 0.30 USDC
45+
46+
- Receiver receives: 9.70 USDC
47+
48+
[See full reference.](https://bridge.thirdweb.com/reference#tag/transfer/POST/v1/transfer/prepare)
49+
50+
### Onramp Fee
51+
52+
When onramping to crypto using the Payments, a fee is charged by the third-party provider. This fee is determined by the provider and is typically a percentage
53+
of the amount being onramped. This fee may vary based on the provider and payment method used.
54+
55+
There are no protocol fees on onramp transactions.

0 commit comments

Comments
 (0)