Developer-controlled wallets simplify user onboarding to your Web3 app by performing blockchain interactions, such as asset transfers and smart contract executions, on behalf of your users. You maintain control of the wallet while removing all of the complexity for your users. This guide describes the best practices for creating and managing developer-controlled wallets to integrate into your app, including how to create wallets for existing users already using your app and new users who sign up later. Scenarios:Documentation Index
Fetch the complete documentation index at: https://circle-devdocs-test-ai-codegen-component.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
- Create wallets for existing users: For onboarding your existing users to developer-controlled wallets, ensuring a smooth transition to the Web3 ecosystem.
- Create wallets for new users in advance: For the routine onboarding of new users to your application. You can create wallets in advance and assign them to users when they sign up.
Prerequisites
- Ensure you complete the Create Your First Developer-Controlled Wallet guide. It provides a comprehensive walkthrough for setting up your first entity secret, wallet set, and wallet, making it an essential foundation for understanding developer-controlled wallets.
Create wallets for existing users
- Batch create and link wallets to existing users: Use the
countparameter with thePOST /developer/walletsAPI endpoint to specify the number of wallets needed per blockchain. Simultaneously, link these wallets to individual users by utilizing themetadataattribute to designate wallet names and associate them with user IDs (e.g., UUID) using therefIdfield for each wallet.
You can create up to 200 wallets per request. If you need more, make additional
requests until you reach the required total.
- Inspect the response payload: After receiving a successful response,
inspect the response body and map the wallet IDs
data.wallets.idwith the respective users on your systems. The response body includes information such as the wallet IDs, custody types, names, and reference IDs.
Response Body
Create wallets for users in advance
Creating wallets in advance streamlines the real-time onboarding process and prevents delays when users require wallets. This approach optimizes the workflow and ensures that wallets are readily available whenever users need them. The following demonstrates best practices:- Invoke the developer-controlled wallets creation API: Utilize the
POST: /developer/walletsendpoint for wallet creation. Specify the number of wallets needed by adjusting thecountparameter.
You can create up to 200 wallets per request. If you need more, make additional
requests until you reach the required total.
Response Body
- Store wallet information: Post-creation, ensure that all relevant wallet information, including wallet IDs and associated attributes (e.g., blockchains, custody types), is securely stored in your system for future reference.
-
Assign the wallet to the user: Once a user requests a wallet, assign one
of the wallets created in the previous step to them. This assignment process
should occur on your system and within Circle’s infrastructure.
- Identify an available pre-created wallet: Select a wallet from your pool of created wallets that hasn’t been assigned yet.
- Associate the selected wallet with the user: Update your database to link the user’s account with the selected wallet. This link should include the wallet’s ID, blockchain information, and any other relevant details to ensure that transactions can be accurately processed and attributed to the correct user.
- Mark the wallet as assigned: To prevent the same wallet from being assigned to multiple users, update its status in your database to indicate that it has now been assigned.
-
Update Circle’s records associating the user and the assigned wallet:
Use the
PUT: /developer/wallets/{id}API to update Circle’s records.
Response Body