Attaching a User Account

Switching library to the full state mode

Login

To set the customer's wallet you should create the account configuration first. Next use the following routine to attach the user account and switch the client object to the full state:

async login(account: AccountConfig): Promise<void>

Parameters

account - an account configuration with credentials and other parameters.

Return value

No return value is required but you must wait until login is completed before the next library interaction.

When login is finished the client will switch into the full mode state and all of the public routines are avialable fo use.

Logout

To set the customer's wallet create the account configuration first. Next, use the following routine to attach the user account and switch the client object to the full state:

async logout(): Promise<void>

Return value

No return value is required but you must wait logout completed before the next library interaction.

When logout is complete the client switches to the account-less state.

Example

The client configuration clientConfig defined in this example

console.log('Attaching account...');
await client.login(accountConfig);
console.log('Seems all right!');

await client.logout();
console.log('See you later...');

Is Account is Attached

Check library is in full mode:

hasAccount(): boolean

Return value

true if account is present and the library is working in full mode or false otherwise.

Example

const res = client.hasAccount()
console.log(`Library operates in ${res ? 'full' : 'account-less'} mode`);

Last updated