Pregenerate Wallets
Wallet pregeneration is a technique where you create wallets for users before they actually sign up or authenticate. This allows you to:
- Pre assign wallets to users before they sign up
- Reduce the time users spend waiting during the onboarding process
- Pre-fund wallets with tokens or NFTs before users claim them
- Create smoother user experiences for gaming and other applications
You can distribute assets to wallets before users claim them, enabling:
- Pre-loaded game assets
- Welcome bonus tokens
- Promotional NFTs
- Airdrops
- Users don't have to wait for wallet to be created during signup
- Reduced failed wallet creation due to network issues
To pregenerate an in-app or ecosystem wallet wallet, you can make a POST
request to the following endpoint:
https://in-app-wallet.thirdweb.com/api/v1/pregenerate
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
{ strategy: "email", email: "[email protected]" }
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.
{ strategy: "phone", phone: "+1321123321" }
{ 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.
You need to include the following headers:
Content-Type
: Must be set toapplication/json
x-secret-key
: Your secret key for authenticationx-ecosystem-id
(optional): Your ecosystem IDx-ecosystem-partner-id
(optional): Your ecosystem partner ID
Here's an example curl command to pregenerate a thirdweb wallet for the user [email protected]
:
Replace the header values with your actual client ID, ecosystem ID, and secret key.
A successful API call returns a JSON object in the following format:
Pre-generating is independent and doesn't change the user's experience.
Your users can continue to login as per usual. When they do, they will be assigned the pregenerated wallet.
For more information on signing in, see Sign In.