SDK Methods for >v0.1.13
Compatible Networks
Optimism Goerli
Ethereum Goerli
Polygon Mumbai
Gnosis
Chiado Gnosis Testnet
Shibuya Testnet
Instance creation and imports
Developers can directly get access to Banana module through our SDK just by importing the banana module from banana-wallet-sdk
Once you successfully import Banana Module, you can start accessing the methods it exposes just by creating an instance of it by specifying the appropriate chain.
You can create a banana Instance as:
Methods by Banana Module
Once the instance is ready, developers can access multiple methods the banana module provides.
Methods offered by the banana module are:
createWallet
connectWallet
getWalletName
getEOAAddress
resetWallet
verifySignature
signBananaMessage (attached with signer)
createWallet
createWallet
the method enables developers to create a wallet for their users. This method should be called only when the user has to create a wallet. Invoking this method prompts the user to enter a name for his wallet once entered the wallet name provided by the user is mapped with the generated wallet. Later on, the user can use this wallet name to access his wallet.
Once the wallet is successfully created this method caches some public wallet metadata at the user's browsers storage to enable the user to fastly connect with his already created wallet using connectWallet
method.
This method doesn't take any param in input as the wallet name-taking process is already hardcoded in it. On successful wallet creation, this method returns a wallet instance. Through this developer can query for provider and signer corresponding to that wallet using getSigner
and getProvider
methods.
Usage
connectWallet
connectWallet
the method is to be used when developers know that the user has already created a wallet on a dapp or the user either knows his wallet name or wallet metadata is present in browser cookie storage (this can be checked using the getWalletName
method). connectWallet
expects a wallet name and it returns a wallet instance from which devs can extract corresponding providers and signers for the wallet.
This method can be used to automatically connect the wallet when the user switches between different pages or reloads a website.
Usage
getWalletName
getWalletName
the method enables developers to read the user's cookie and retrieve the saved wallet name for display purposes. If this method does not return anything, it indicates that the user may have cleared their cookies. In such cases, developers should manually prompt the user for the wallet name.
Usage
getEOAAddress
getEOAAddress
the method enables developers to retrieve the q values, which are the public address representation of the address generated by the device. The q values returned can be used for verifying the signature.
Usage
isWalletNameUnique
isWalletNameUnique
the method enables developers to check if the wallet name suggested by their user is unique or not. This is possible because the wallet name serves as the primary key in the wallet credentials database on our server. As a suggestion, users can choose to keep their Gmail account username as their wallet name, as it is always unique.
Usage
resetWallet
resetWallet
the method enables developers to clear the current wallet metadata from the cookie's local storage. This enables the user to deploy a new wallet with a new username if needed. The method does not delete the existing wallet; instead, the user can roll back and use their previous wallet on the dapp by simply entering their previous wallet username by passing the previous walletName in connectWallet
method. This method does not require any input parameters and does not return any values. Developers can call it directly to clear the wallet metadata.
Usage
verifySignature
verifySignature
Developers can utilize the verifySignature
method of bananaInstance
to verify the signed message signature against the user's hardware (EOA) address. The method expects three arguments: signature, messageSigned, and eoaAddress.
Usage
signBananaMessage
signBananaMessage
As banana-wallet-sdk provides touchid-based wallets to users. And the signature generated from the hardware infra of the device is r1 type signature which is different from the current k1-based signature scheme. k1 based signature schemes are unique with respect to messages signed means for each message signed we can receive only one unique signature. In r1 based signature mechanism as the hardware of the device in itself adds some sort of entropy to the message it returns a different signature string for the same message if tried repeatedly. Due to this it makes sense to return the signature and the actual message which is signed.
That's why we attached a new method called signBananaMessage
to signer which takes in the message as a string and returns an object containing messageSigned (the message which is generated from device hardware after adding entropy) and the signature.
Usage
PS: if after following this documentation you are experiencing webpack polyfill issue please refer to this page
đ§Webpack 5 Polyfill IssueIf you have any questions please post them Banana SDK Discord forum.
Last updated