Generate Wallet
Before getting around to generating wallets for your users, it is assumed you already have your platform's authentication system and user management system in place. This is important as you will need to associate the wallets you create with your users using, in this case, an
appID
that serves as a linker to a specific user and anauth-token
assigned after user authentication.
Generating Wallets
To generate a new wallet for a user, you will need to make a request to the following GraphQL endpoint:
The request to be constructed will be in the form of the following GraphQL query:
In the query above, the symbol
field represents the cryptocurrency wallet you want to create. The appId
field is the unique identifier of the user you want to create the wallet for.
Required Fields
Field | Type | Description |
---|---|---|
symbol | String | The symbol of the cryptocurrency you want to create a wallet for. |
appId | String | The unique identifier of the user you want to create the wallet for. |
Sending the Request
To send the request, you can create a function that executes the query in any language of your choice. Below is an example of how you can do this in TypeScript:
In the code block above, the createUserWallet
function is defined to make a request to the GraphQL server using the query variable we created earlier. The function takes in the auth-token
of the user making the request, the symbol
of the cryptocurrency wallet to be created, and the appId
of the user the wallet is being created for. Using these, a wallet of choice is created for the user.
If you are also using TypeScript/JavaScript, and you are curious about the graphqlRequest
helper function, here is a glimpse of what it contains:
The graphqlRequest
function is a helper function that sends a POST request to the specified URL with the provided options. It also handles any errors that may occur during the request and returns a GraphQLResponse
object with the data and any errors encountered.
The type definition for GraphQLRequestOptions
and GraphQLResponse
are shown below:
Summary
Completato. With this you should be able to generate crypto wallets for your platform users. Creating wallets for your users is a crucial part of your platform's functionality. By following the steps outlined above, you can easily generate wallets for your users and associate them with their accounts using the appId
and auth-token
fields. This way, users can have a seamless experience managing their cryptocurrency assets on your platform.