Ebakus Wallet Loader
The wallet library creates an iframe and loads the web wallet library in there. It can accept custom configurations for the wallet (i.e. load custom tokens) and act as an interface between the dApp and the web wallet iframe. This way a user can use his wallet to interface with any ebakus dApp she wants without having to create new keys and manage multiple accounts.
You can check how it looks like inside an existing dApp.
The boilerplate
The best way to start is to use the dApp Boilerplate, where you can see how you can use the wallet loader library to programatically:
- Send transactions
- Deploy contracts
- Interact with smart contracts
- Configure custom tokens
Contact us at hello@ebakus.com.
Have fun!
Load package
Using npm
npm install --save ebakus-web-wallet-loader
and use it like:
ebakusWallet // you have to load the wallet once
With a script tag from your site
In your dApp page you have to include our Wallet Loader script.
Load it from CDN:
or copy it to your site:
The script will expose window.ebakusWallet
. You can also have a look at the example page.
You will have to init the loader once using:
ebakusWallet
API
The dApp can communicate with the wallet through the loader API.
Events
ebakusLoaded
When loader has finished loading with the wallet loading it will dispatch the ebakusLoaded
event.
window
ebakusCurrentProviderEndpoint
Every time the user switches the connected node the wallet will dispatch the ebakusCurrentProviderEndpoint
event.
window
ebakusConnectionStatus
Every time the wallet connection with the node changes it will dispatch the ebakusConnectionStatus
event.
window
ebakusAccount
Every time switches account in the wallet it will dispatch the ebakusAccount
event.
window
ebakusBalance
On wallet balance change it will dispatch the ebakusBalance
event.
window
ebakusStaked
On wallet staked amount change it will dispatch the ebakusStaked
event.
window
Methods
ebakusWallet.init(options)
The init
method can be used in order to pass custom configuration for the actual wallet.
You can:
- point the walletLoader to your own instance of the Ebakus Wallet
- set custom tokens for your dApp
// loading custom token to walletebakusWallet window
ebakusWallet.isWalletFrameLoaded()
The isWalletFrameLoaded
method returns if the wallet frame has finished loading.
if ebakusWallet // do something
ebakusWallet.getCurrentProviderEndpoint()
The getCurrentProviderEndpoint
method returns the wallet used web3 endpoint so as the dApp can connect to the same provider.
ebakusWallet
ebakusWallet.unlockWallet()
The unlockWallet
method will ask your user to unlock the wallet in case it is locked. This is not needed most times as the wallet will ask on the first wallet interaction, when needed.
ebakusWallet
ebakusWallet.getAccount()
The getAccount
method returns the wallet address or an exception if no account address exists.
ebakusWallet
ebakusWallet.getBalance()
The getBalance
method returns the wallet balance.
ebakusWallet
ebakusWallet.getStaked()
The getStaked
method returns the wallet staked amount.
ebakusWallet
ebakusWallet.sendTransaction(tx)
The sendTransaction
method will ask user to confirm, sign and send the transaction at the network through the wallet.
ebakusWallet
ebakusWallet.unloadWallet()
The unloadWallet
method will remove the wallet instance already loaded in the dApp. You can then call init
again when needed.
ebakusWallet
Development
Install dependencies
npm install
Compile for development (with hot-reload support)
npm start
Compile and minify for production
npm run build