Skip to main content

Enroll Users

Enrolling users is a crucial functionality provided by the edeXa Token engine SDK. To enroll a new user, you can utilize the enrollUser method.


Prerequisites


Sample Code Snippet

Here is a JavaScript code snippet demonstrating the use of the enrollUser method:

// SDK.js
import { ERC20, Network } from 'edeXa-sdk';

async function enrollUser() {
const erc20 = new ERC20({
...settings,
authorization: `Bearer ${token}`,
});

const settings = {
network: Network.SANDBOX, // or Network.MAINNET for the mainnet network
};

const dataToEnrollUser = {
email: 'user@example.com',
firstName: 'John',
lastName: 'Doe',
};

try {
const enrollUserResponse = await erc20.enrollUser(dataToEnrollUser);
// Handle success
} catch (error) {
// Handle error
}
}

Important Notes

  • Authentication Token: Replace the token in the authorization header with your actual authentication token.
  • Asynchronous Execution: The enrollUser function is an async function, using await to pause execution until the erc20.enrollUser promise resolves. If successful, the response will be logged. Errors are caught and logged with console.error.
  • User Information: Provide the necessary user information in the dataToEnrollUser object.

Request Parameters

The dataToEnrollUser object requires the following parameters:

ParameterRequiredTypeDescription
emailYesStringThe email of the user
firstNameYesStringThe first name of the user
lastNameYesStringThe last name of the user

Response Format

The response from the enrollUser method includes the following attributes:

KeyTypeDescription
firstNameStringFirst name of the user
lastNameStringLast name of the user
uuidStringUnique identifier of the user
emailStringEmail address of the user
_idStringDatabase ID of the user