Version: Next

Lamden Wallet Controller API

walletController.js

constructor([connectionRequest])

Lamden Wallet Controller Class

This Class interfaces with the Lamden Wallet's content script. It provids helper methods for creating a connection, getting wallet info, sending transactions and retreiving tx information.

The connection information for your DAPP can be supplied now or later by calling "sendConnection" manually.

IMPORTANT: The window object needs to be available when creating this instance as it will attempt to create listeners.

Parameters

NameTypeDescription
connectionRequestObjectA connection request objectOptional
connectionRequest.appNamestringThe name of your dApp 
connectionRequest.versionstringConnection version. Older version will be over-written in the uers's wallet. 
connectionRequest.contractNamestringThe smart contract your DAPP will transact to 
connectionRequest.networkTypestringWhich Lamden network the approval is for (mainnet or testnet) are the only options 
connectionRequest.logostringThe reletive path of an image on your webserver to use as a logo for your Lamden Wallet Linked Account 
connectionRequest.backgroundstringThe reletive path of an image on your webserver to use as a background for your Lamden Wallet Linked AccountOptional
connectionRequest.charms.namestringCharm nameOptional
connectionRequest.charms.variableNamestringSmart contract variable to pull data fromOptional
connectionRequest.charms.keystringKey assoicated to the value you want to lookupOptional
connectionRequest.charms.formatAsstringWhat format the data isOptional
connectionRequest.charms.iconPathstringAn icon to display along with your charmOptional

Returns

  • WalletController

getInfo()

Creates a "lamdenWalletGetInfo" CustomEvent to ask the Lamden Wallet for the current information. This will fire the "newInfo" events.on event

walletIsInstalled()

Check if the Lamden Wallet extention is installed in the user's broswer.

This will fire the "newInfo" events.on event

Returns

  • Promise Wallet is Installed.

sendConnection([connectionRequest])

Send a connection to the Lamden Wallet for approval. If the connectionRequest object wasn't supplied to the construtor then it must be supplied here.

This will fire the "newInfo" events.on event

Parameters

NameTypeDescription
connectionRequestObjectA connection request objectOptional
connectionRequest.appNamestringThe name of your dApp 
connectionRequest.versionstringConnection version. Older version will be over-written in the uers's wallet. 
connectionRequest.contractNamestringThe smart contract your dApp will transact through 
connectionRequest.networkTypestringWhich Lamden network the approval is for (Mainnet or testnet) 
connectionRequest.backgroundstringA reletive path to an image to override the default lamden wallet account backgroundOptional
connectionRequest.logostringA reletive path to an image to use as a logo in the Lamden Wallet 
connectionRequest.charms.namestringCharm nameOptional
connectionRequest.charms.variableNamestringSmart contract variable to pull data fromOptional
connectionRequest.charms.keystringKey assoicated to the value you want to lookupOptional
connectionRequest.charms.formatAsstringWhat format the data isOptional
connectionRequest.charms.iconPathstringAn icon to display along with your charmOptional

Returns

  • Promise The User's Lamden Wallet Account details or errors from the wallet

sendTransaction(tx[, callback])

Creates a "lamdenWalletSendTx" event to send a transaction request to the Lamden Wallet.
If a callback is specified here then it will be called with the transaction result.

This will fire the "txStatus" events.on event

Parameters

NameTypeDescription
txObjectA connection request object 
tx.networkTypestringWhich Lamden network the tx is for (Mainnet or testnet) 
tx.stampLimitstringThe max Stamps this tx is allowed to use. Cannot be more but can be less. 
tx.methodNamestringThe method on your approved smart contract to call 
tx.kwargsObjectA keyword object to supply arguments to your method 
callbackFunctionA function that will called and passed the tx results.Optional

constructor(connectionRequest)

Wallet Connection Request Class Validates and stores the information from a connectionRequest object. See WalletController constructor for connection request params.

Parameters

NameTypeDescription
connectionRequestObject- request object 

Returns

  • WalletConnectionRequest

getInfo()

Get a JSON string of the approval request information

Returns

  • string - JSON string of all request information