EvanCoreService¶
Source | core |
---|
Core service for angular-core that handles dapp-browser connections, active accounts, current provider and more.
agentUrl
-string
: base url of the evan.network smart agents server
getCurrentProvider¶
coreService.getCurrentProvider();
Get the current configured current provider
Parameters¶
options
-object
: The options used for callingfrom
-string
(optional): The address the call “transaction” should be made from
callback
-Function
(optional): This callback will be fired..somethingElse
-string
(optional): this can be set if required, defaults to"latest"
Returns¶
string
: The current provider. (internal / external)
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
setCurrentProvider¶
coreService.setCurrentProvider(provider);
Sets the current provider that should be used.
Parameters¶
provider
-string
: provider to switch to
activeAccount¶
coreService.activeAccount();
Get the current selected account included the check of the current provider.
Returns¶
string
: active account
getAccountId¶
coreService.getAccountId();
Returns the current saved account id from localStorage
Returns¶
string
: get account id from local storage
setAccountId¶
coreService.setAccountId(accountId);
Sets an account id as active one to the local storage.
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¶
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¶
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¶
stringToCopy
-string
: text that should be copiedtoastMessage
-string
(optional): Provide a custom toast message
Example¶
coreService.copyString('Copy me :)');