Pregenerate User Wallets
To pregenerate an embedded wallet, you can make a POST
request to the following endpoint:
https://embedded-wallet.thirdweb.com/api/v1/pregenerate
This allows you to safely create wallet addresses for your users before they login to your app.
Request Body
The request body should be a JSON object with the following parameters:
strategy
: The strategy for wallet generationemail
orphone
oruserId
: The user identifier associated with the wallet to be generated
Email based wallets
{ strategy: "email", email: "user@example.com" }
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.
Phone based wallets
{ strategy: "phone", phone: "+1321123321" }
Custom user id based wallets
{ strategy: "custom_auth_endpoint", userId: "some_user_id" }
Use this when bringing your own authentication method. When the user logs in, if the user ids you provide from the auth endpoint match, they will get access to the same pregenerated wallet.
Headers
You need to include the following headers:
x-ecosystem-id
: Your ecosystem IDx-secret-key
: Your secret key for authenticationContent-Type
: Must be set toapplication/json
Example curl Command
Here's an example curl command to pregenerate an embedded wallet:
Replace the header values with your actual client ID, ecosystem ID, and secret key.
Response Format
The API returns a JSON object. The exact structure may vary based on the implementation, but it typically includes information about the pregenerated wallet. Here's a possible structure:
Note: The actual response may include additional fields or have a different structure. Please refer to the most up-to-date documentation for the exact response format.
Remember to handle the response appropriately in your chosen programming language, including error cases and parsing the JSON response.