Methods Usage Latest

import { Banana, 
       } from '@rize-labs/banana-wallet-sdk'

 * Banana Module:
 * This module will be responsible to deliver everything related to account abstraction
 * , smart contract wallets and touchId authentication i.e 4337 based provider, wallets etc

 * Banana Module Initialization
 * @params chain enum
 * @returns Banana Class instance
const bananaInstance = new Banana(Chains.goerli);

 * @params none
 * @returns walletName: string
 * accessed from the banana instance and used to fetch walletname.
 * cached in the user's cookie storage 
const someWalletName: string = bananaInstance.getWalletName();

// when the user doesn't possess a wallet. createWallet method can be used to createWallet for user

// createWallet method has inbuilt prompts for walletname and wallet name uniqueness checkers it opens up
// a walletname input field in separate page and closes once the user enter's unique walletname
const walletInstance: Wallet = await bananaInstance.createWallet();

// when the user already has a wallet. This username can be given directly by the user
// or fetched by dev using getWalletName() method
const walletInstanceFromConnect: Wallet = await bananaInstance.connectWallet(someWalletName);

// method which returns provider which can be further used to retrieve signer and initialize contract
const bananaProvider: Banana4337Provider = await walletInstance.getProvider();

// extracting bananSigner
const bananaSigner: BananaSigner = await walletInstance.getSigner();

// initializing sample greeter contract with aaSigner
const GreeterContract = new ethers.Contract(

// greeter contract greet calldata
const greetCallData = GreeterContract.interface.encodeFunctionData(

// to send transaction
const txn = {
   to: addresses.Greeter,
   from: walletInstance.getAddress(),
   value: 0,
   data: greetCallData

const txn = bananaSigner.sendTransaction(txn);

await txn.wait(); // waiting for txn to complete

//Similarly signing and verifying messages the flow looks like

 * @method verify
 * @param { string } signature, { string } messageSigned, { string } eoaAddress
 * @returns { boolean } isSignatureValid
 * method to verify message against signature
const sampleMsg = "Hello World";
const eoaAddress = bananaInstance.getEOAAddress();
const signMessageResponse = await bananaSigner.signBananaMessage(sampleMsg);
const signature = signMessageResponse.signature;
const isSignatureValid = await bananaInstance.verifySignature(signature, sampleMsg, eoaAddress);

If you have any questions please post them Banana SDK Discord forum.

Last updated