EvanCoreService

Source core

Core service for angular-core that handles dapp-browser connections, active accounts, current provider and more.

  1. agentUrl - string: base url of the evan.network smart agents server

getCurrentProvider

coreService.getCurrentProvider();

Get the current configured current provider

Parameters

  1. options - object: The options used for calling
    • from - string (optional): The address the call “transaction” should be made from
  2. callback - Function (optional): This callback will be fired..
  3. somethingElse - string (optional): this can be set if required, defaults to "latest"

Returns

string: The current provider. (internal / external)

Example

coreService.getCurrentProvider();

finishDAppLoading

coreService.finishDAppLoading();

Hides the initial loading that is embedded to the root dapp html page. => It will disappear smooth and will be removed when animation is over

Example

coreService.finishDAppLoading();

isInternalProvider

coreService.isInternalProvider();

Check if we should use internal provider.

Returns

boolean: True if internal provider, False otherwise.


getExternalProvider

core.getExternalProvider();

Checks if a injected web3 provider exists an returns it’s name

Returns

boolean: check if the current provider is external

Example

getExternalProvider()
// false

setCurrentProvider

coreService.setCurrentProvider(provider);

Sets the current provider that should be used.

Parameters

  1. provider - string: provider to switch to

Example

coreService.setCurrentProvider('internal')

activeAccount

coreService.activeAccount();

Get the current selected account included the check of the current provider.

Returns

string: active account

Example

coreService.activeAccount();

getAccountId

coreService.getAccountId();

Returns the current saved account id from localStorage

Returns

string: get account id from local storage

Example

coreService.getAccountId();

setAccountId

coreService.setAccountId(accountId);

Sets an account id as active one to the local storage.

Parameters

  1. accountId - string: account id to set

Example

coreService.setAccountId('0x00');

getExternalAccount

coreService.getExternalAccount();

Checks if an external provider is activated and returns it’s active account id

Returns

string: The external account.

Example

coreService.getExternalAccount()
// '0x000...'

currentBrowser

coreService.currentBrowser();

Return the name of the current used browser => https://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser

Returns

string : opera / firefox / safari / ie / edge / chrome

Example

coreService.currentBrowser();
// 'chrome'

getBalance

coreService.getBalance(accountId);

Gets the balance of the provided or current account id

Parameters

  1. accountId - string: account id to get the balance from (default coreService.activeAccount())

Returns

number : The balance for the specific account id

Example

coreService.getBalance('0x000');
// 6.0223

logout

coreService.logout(disabledReload);

Logout the current user. Removes the active account, provider and terms of use acceptance.

Parameters

  1. disabledReload - boolean: The options used for calling

Example

coreService.logout();

copyString

coreService.copyString(arguments);

Copes a string into the users clipboard and shows an toast, including the copied text

Parameters

  1. stringToCopy - string: text that should be copied
  2. toastMessage - string (optional): Provide a custom toast message

Example

coreService.copyString('Copy me :)');