Create Sub Account Wallets
Introduction
Sub account wallet is everything the cryptocurrency wallets created in the previous section are, but with a little twist. While wallets are specific to users, sub-accounts provides a new revolutionary way of managing wallets on your platform, by creating wallets as subsidiary accounts of a central wallet; this will be discussed in more details in the subsequent sections.
Sub Accounts
Sub accounts is a feature that makes provisions for subsidiary wallets to be created but pegged to a defined main account. With this architecture, all funds are stored in the central account (otherwise called main account), rather than generating separate wallets for users and storing crypto in a diversified pattern. This makes it easier to keep track of balances, and manage incomings and outgoings on your system.
The sub accounts created for each user can then contain references which would be used to keep them updated as to the user balances, and their transaction history. While the user's still have wallet addresses, upon deposits, the fund is routed to the main account, and transaction logs are made to ensure the user account is updated too.
Steps to Creating Sub Accounts
When creating sub accounts, the most important properties are the symbols
, networks
and owner
. The owner
object contains fields such as the name
and email
fields. The email
property can serve as your key/unique identifier for your users, as no two users can have the same email addresses. Using this, you can determine if a user already has a sub account, and create additional wallets within the same sub account for the user. There is also a metadata
field that takes in an array of objects, and let's you define custom key-value pairs to add as you see fit, offering flexibility. You can decide to change your method to feature another property for your key if you so desire. To create sub accounts, you can choose to get user details via input on your platform, and store it in the following format:
The metadata
field can be used to store additional information about the addresses, userID, etc. This can be useful for KYC purposes, and for keeping track of user information. The table below shows the properties that can be used to create sub accounts:
Property | Description | Type | Required |
---|---|---|---|
symbols | The cryptocurrency symbol | Array | Yes |
networks | The blockchain network | Array | Yes |
owner | The owner of the sub account | Object | Yes |
metadata | Additional information | Array | No |
To create a sub account, follow the steps outlined below:
- Step 1: Get the user details using your preferred method (e.g input fields).
- Step 2: Store the user details in the format shown above.
- Step 3: Make a POST request as shown in the code snippet below (Note that otherwise stated, code blocks are in TypeScript):
In the code snippet above, the pub_keys[0].value
is the your public API key which can be gotten from your 100Pay dashboard. The data
object contains the user details in the format shown above. The response from the API call will contain the sub account details created for the user.
Conclusion
With this, you can create sub accounts for your users, and manage their wallets in a more organized manner. This feature is particularly useful for platforms that require a more organized way of managing user wallets, and keeping track of their balances and transaction history. The next section will discuss how to manage user balances and transaction history.