Skip to content

Commit 8bb2b0a

Browse files
[Docs] Update pregenerate wallets API endpoint and request format (#7791)
1 parent 5f82df1 commit 8bb2b0a

File tree

2 files changed

+69
-19
lines changed

2 files changed

+69
-19
lines changed

apps/portal/src/app/wallets/custom-auth/page.mdx

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,31 @@ You will be asked to enter the following values
5757

5858
### Usage example
5959

60-
<Tabs defaultValue="typescript">
60+
<Tabs defaultValue="http">
6161
<TabsList>
62+
<TabsTrigger value="http">HTTP</TabsTrigger>
6263
<TabsTrigger value="typescript">TypeScript</TabsTrigger>
6364
<TabsTrigger value="react">React</TabsTrigger>
6465
<TabsTrigger value="dotnet">.NET</TabsTrigger>
6566
</TabsList>
6667

68+
<TabsContent value="http">
69+
70+
```http
71+
POST https://api.thirdweb.com/v1/wallets/user/generic-auth
72+
Content-Type: application/json
73+
x-client-id: <your-client-id>
74+
x-ecosystem-id: <your-ecosystem-id> (optional)
75+
x-ecosystem-partner-id: <your-ecosystem-partner-id> (optional)
76+
77+
{
78+
"type": "jwt",
79+
"jwt": "<your-jwt>"
80+
}
81+
```
82+
83+
</TabsContent>
84+
6785
<TabsContent value="react">
6886

6987
```typescript
@@ -81,7 +99,7 @@ const handlePostLogin = async () => {
8199
wallet.connect({
82100
client,
83101
strategy: "jwt",
84-
jwt: "<your-jwt-token>",
102+
jwt: "<your-jwt>",
85103
});
86104
return wallet;
87105
});
@@ -107,7 +125,7 @@ const wallet = inAppWallet();
107125
const account = await wallet.connect({
108126
client,
109127
strategy: "jwt",
110-
jwt: "<your-jwt-token>",
128+
jwt: "<your-jwt>",
111129
});
112130

113131
// use the account to send transactions
@@ -122,7 +140,7 @@ using Thirdweb;
122140

123141
var client = ThirdwebClient.Create(clientId: "your-client-id");
124142
var wallet = await InAppWallet.Create(client: client, authProvider: AuthProvider.JWT);
125-
var address = await wallet.LoginWithCustomAuth(jwt: "<your-jwt-token>");
143+
var address = await wallet.LoginWithCustomAuth(jwt: "<your-jwt>");
126144
```
127145

128146
</TabsContent>
@@ -170,13 +188,33 @@ You can also pass a list of headers. These headers will be sent with every reque
170188

171189
Once you've logged in with your own auth, you can pass the user's JWT to the in-app wallet to authenticate and connect.
172190

173-
<Tabs defaultValue="typescript">
191+
<Tabs defaultValue="http">
174192
<TabsList>
193+
<TabsTrigger value="http">HTTP</TabsTrigger>
175194
<TabsTrigger value="typescript">TypeScript</TabsTrigger>
176195
<TabsTrigger value="react">React</TabsTrigger>
177196
<TabsTrigger value="dotnet">.NET</TabsTrigger>
178197
</TabsList>
179198

199+
<TabsContent value="http">
200+
201+
```http
202+
POST https://api.thirdweb.com/v1/wallets/user/generic-auth
203+
Content-Type: application/json
204+
x-client-id: <your-client-id>
205+
x-ecosystem-id: <your-ecosystem-id> (optional)
206+
x-ecosystem-partner-id: <your-ecosystem-partner-id> (optional)
207+
208+
{
209+
"type": "auth-payload",
210+
"payload": "<your-auth-payload>"
211+
}
212+
```
213+
214+
215+
216+
</TabsContent>
217+
180218
<TabsContent value="react">
181219

182220
```typescript
@@ -214,8 +252,6 @@ const MyComponent = () => {
214252

215253
<TabsContent value="typescript">
216254

217-
In other frameworks, use your own instance of the wallet to authenticate and connect.
218-
219255
```typescript
220256
import { inAppWallet } from "thirdweb/wallets";
221257

apps/portal/src/app/wallets/pregenerate-wallets/page.mdx

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const metadata = createMetadata({
77
icon: "wallets",
88
},
99
title: "Pregenerate Wallets | thirdweb",
10-
description: "Create wallets before users sign up with thirdwebs wallet pregeneration. Pre-fund with tokens, NFTs, or game assets to enable smooth onboarding and asset claiming.",
10+
description: "Create wallets before users sign up with thirdweb's wallet pregeneration. Pre-fund with tokens, NFTs, or game assets to enable smooth onboarding and asset claiming.",
1111
});
1212

1313
# Pregenerate Wallets
@@ -35,35 +35,48 @@ You can distribute assets to wallets before users claim them, enabling:
3535

3636
To pregenerate an in-app or ecosystem wallet wallet, you can make a `POST` request to the following endpoint:
3737

38-
```
39-
https://in-app-wallet.thirdweb.com/api/v1/pregenerate
38+
```http
39+
POST https://api.thirdweb.com/v1/wallets/user/pregenerate
40+
Content-Type: application/json
41+
x-secret-key: <your-secret-key>
42+
x-ecosystem-id: <your-ecosystem-id> (optional)
43+
x-ecosystem-partner-id: <your-ecosystem-partner-id> (optional)
44+
45+
{
46+
"type": "email",
47+
"email": "[email protected]"
48+
}
4049
```
4150

4251
## Request Body
4352

4453
The request body should be a JSON object with the following parameters:
4554

46-
- `strategy`: The strategy for wallet generation
47-
- `email` or `phone` or `userId`: The user identifier associated with the wallet to be generated
55+
- `type`: The type of wallet identifier to pregenerate a wallet for:
56+
- Email based: `email`, `google`, `facebook`, `discord`
57+
- Phone based: `phone`
58+
- Wallet based: `signer`
59+
- User ID based: `custom_jwt` or `custom_auth_endpoint`
60+
- `email` or `phone` or `userId` or `walletAddress`: The user identifier associated with the wallet to be generated
4861

4962
### Email based wallets
5063

5164
```
52-
{ strategy: "email", email: "[email protected]" }
65+
{ type: "email", email: "[email protected]" }
5366
```
5467

5568
When the user logs in with any method associated with that email (including google, facebook, discord auth), they will get access to the same pregenerated wallet.
5669

5770
### Phone based wallets
5871

5972
```
60-
{ strategy: "phone", phone: "+1321123321" }
73+
{ type: "phone", phone: "+1321123321" }
6174
```
6275

6376
### Custom user id based wallets
6477

6578
```
66-
{ strategy: "custom_auth_endpoint", userId: "some_user_id" }
79+
{ type: "custom_auth_endpoint", userId: "some_user_id" }
6780
```
6881

6982
{/* TODO: update link when custom auth documentation has been updated */}
@@ -83,13 +96,13 @@ You need to include the following headers:
8396
Here's an example curl command to pregenerate a thirdweb wallet for the user `[email protected]`:
8497

8598
```bash
86-
curl -X POST 'https://in-app-wallet.thirdweb.com/api/v1/pregenerate' \
99+
curl -X POST 'https://api.thirdweb.com/v1/wallets/user/pregenerate' \
87100
-H 'x-ecosystem-id: ecosystem.example-eco-123' \
88101
-H 'x-ecosystem-partner-id: 1415d24e-c7b0-4fce-846e-740841ef2c32' \
89-
-H 'x-secret-key: 9f8e7d6c5b4a3f2e1d0c9b8a7ffge434b2a1f0e9d8c7b6a5f4e3d2c1b0a9f8e7' \
102+
-H 'x-secret-key: <your-project-secret-key>' \
90103
-H 'Content-Type: application/json' \
91104
-d '{
92-
"strategy": "email",
105+
"type": "email",
93106
"email": "[email protected]"
94107
}'
95108
```
@@ -107,9 +120,10 @@ A successful API call returns a JSON object in the following format:
107120

108121
```json
109122
{
110-
"wallet": {
123+
"result": {
111124
"address": "string",
112125
"createdAt": "string",
126+
"profile": "object[]"
113127
}
114128
}
115129
```

0 commit comments

Comments
 (0)