Skip to main content

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, leveraging await to hold execution until the bstamp.enrollUser promise completes.
  • Token Replacement: Make sure to replace token used in Authorization with your token, which you will get in response of authentication method

Request Parameters

ParameterRequiredTypeDescription
userIdYesStringUser ID of the user to whom you want to enroll
usernameYesStringUsername of the user to whom you want to enroll
emailYesStringEmial of the user to whom you want to enroll

Response Format

KeyTypeDescription
publicAddressStringThe public address of the user you enrolled
userIdStringThe user ID of the user you enrolled