Enroll User
To register a user with the bStamp API, utilize the enrollUser
method from the SDK.
Sample Code Snippet
Here is a JavaScript code snippet demonstrating the use of the enrollUser
method:
import { Bstamp, Network } from 'edeXa-sdk';
async function enrollUser() {
const bStamp = new Bstamp({
...settings,
authorization: `Bearer ${token}`,
});
const settings = {
network: Network.SANDBOX, // or Network.MAINNET for the mainnet network
};
const dataToEnrollUser = {
userId: 'USER_ID',
username: 'USER_NAME',
email: 'EMAIL'
}
try {
const enrolledUserDetails = await bstamp.enrollUser(dataToEnrollUser);
// Handle success
} catch (error) {
// Handle error
}
}
Key Points to Note
- Asynchronous Function: The
enrollUser
function operates as an asynchronous (async
) function, leveragingawait
to hold execution until thebstamp.enrollUser
promise completes. - Token Replacement: Make sure to replace
token
used inAuthorization
with yourtoken
, which you will get in response of authentication method
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
userId | Yes | String | User ID of the user to whom you want to enroll |
username | Yes | String | Username of the user to whom you want to enroll |
Yes | String | Emial of the user to whom you want to enroll |
Response Format
Key | Type | Description |
---|---|---|
publicAddress | String | The public address of the user you enrolled |
userId | String | The user ID of the user you enrolled |