What is it?
The Lamden Wallet Controller (LWC) is a helper package for interacting with the Lamden Wallet API via a webpage. You can interact with the Lamden Wallet API without this package, but the intent here is to replace the process of managing listeners and events with a more modern callback/Promise workflow.
- add walletController.js to your project.
- import into project
- install via NPM
- import into your project
Create Connection Request Object
Creating a connection request is the same as Lamden Wallet API - Create a Connection.
Below is the mandatory information for a connection request but more customization optons are available.
Create an Instance of the LWC
Respond to Events from the LWC
Check if Wallet is Installed
walletIsInstalled will return a promise with the resolver being a boolean value as to the installed status of the wallet.
If the wallet is installed the LWC will automatically send your connection request and the user will see the New Linked Account popup process.
Once the user completes the popup process you will get the wallet Info on the
newInfo event emitter.
So to recap, the
walletIsInstalled method will accomplish 3 things:
- Reports back the installed status of the wallet.
- If installed is true and a connection request was provided to the constructor then it will automatically create the
lamdenWalletConnectevent and provide your connection request to the users Lamden Wallet
- If the user has a Linked Account for your DAPP you will be sent the Wallet Information on the
newInfolistener; or else the user will compelte the New Linked Account process and you will be proveded the Wallet Information at that point.
Send Connection Request
Not required if you have already called
sendConnection can be used if you didn't supply the connectionRequest information to the wallet previously or if you want to submit another connection request.
If the user has a Linked Account for your DAPP you will be sent the Wallet Information on the
newInfo listener; or else the user will compelte the New Linked Account process and you will be proveded the Wallet Information at that point.
Send A Transaction
Create the transaction object as per the Lamden Wallet API specification.
contractNameis automatically filled in by the LamdenWallet with the value approved by the user in your connection request.
You always get the transaction results on the
txStatus event emitter weither a callback is defiened or not.