SDK Methods for v0.1.13
Compatible Networks
Optimism Goerli
Ethereum Goerli
Polygon Mumbai
Instance creation and imports
Devs can directly get access to Banana module through our SDK just by importing the banana package 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, devs can access multiple methods provided by the banana module.
Methods offered by the banana module are:
createWallet
connectWallet
execute
getWalletName
getBananaProvider
getEOAAddress
isWalletNameUnique
resetWallet
signMessage
verifySignature
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. It expects a unique wallet name and returns the object containing the process status and generated wallet address the uniqueness of the wallet name entered by the user can be checked via isWalletNameUnqiue
. Once the wallet is created the wallet metadata would be saved to the user's browser cookie storage.
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 walletName and it returns an object containing process status and walletAddress.
Usage
execute
execute
Developers can utilize the execute method of banana to execute a transaction via users' smart contract wallet. To use this method, developers must pass on callData
a function (call data of function which user wants to call), destination address (contract address whose function is getting called), and value (in case of payable function is called).
For now, we are supporting single transaction execution. Bundling is under development.
Please don't use this method for view function calls. For just to read any contract data you can directly call it from your contract instance.
Usage
getWalletName
The 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
getBananaProvider
getBananaProvider
The getBananaProvider
the method enables developers to obtain ERC 4337-based providers for their smart contract wallet, which they can use in various ways, including creating contract instances with signers.
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
the function. 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
signMessage
signMessage
Developers can utilize the signMessage
method of bananaInstance
to enable users to sign messages using their wallets. During signing, the message passed will be hashed and then signed by the wallet. The method expects only one argument, which is the message to be signed, and returns an object containing the actual message that was signed and the signature.
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
PS: if after following this documentation you are experiencing webpack polyfill issue please refer to this page
đ§pageWebpack 5 Polyfill IssueIf you have any questions please post them Banana SDK Discord forum.
Last updated