Methods Usage <v0.1.13
import { Banana } from '@rize-labs/banana-wallet-sdk/dist/BananaProvider'
import { Chains } from '@rize-labs/banana-wallet-sdk/dist/Constants'
/**
* Banana Module:
* This module will be responsible to deliver everything related to account abstraction
* , smart contract wallets and touchId authentication i.e aaProvider, walletAddress, walletapi etc
*/
/*
* Banana Module Initialization
* @params chain enum and JsonRpcUrl
* @returns Banana Class instance
*/
const jsonRpcUrl = 'https://eth-goerli.g.alchemy.com/v2/<Alchemy goerli api key>';
const bananaInstance = new Banana(Chains.goerli, jsonRpcUrl);
/*
* @params none
* @returns walletName: string
* accessed from banana instance and used to fetch walletname.
* cached in user's cookie storage
*/
const walletName: string = bananaInstance.getWalletName();
// In case walletName is not fetched, the dev needs to prompt the user to enter the walletName which he had
// previously used with the dapp. In case user hasn't created any wallet with the dapp dev can promt
// user for new wallet name for his wallet.
/*
* @params walletName: string
* @returns isUnique: bool
* @nature async
* accessed from banana instance and be used to check if walletName
* for new wallet provided by user is unique or not
*/
const isUnqiue: boolean = await bananaInstance.isWalletNameUnique(walletName);
/*
* @params walletName: string
* @returns Smart Contract Wallet Address: string
* @nature async
*/
/*
* Method behavior
* In case the user already has a wallet with walletName name the method will return the
* smart contract wallet address for that walletName.
* In case the user don't have a wallet with walletName name the method will return the
* smart contract wallet address for the newly created wallet.
*/
const walletAddress: string = await bananaInstance.getWalletAddress(walletName);
// method which returns provider which can be further used to retrieve signer and initialize contract
const aaProvider = await bananaInstance.getAAProvider(walletAddress);
// extracting aaSigner
const aaSigner = aaProvider.getSigner();
// initializing sample greeter contract with aaSigner
const GreeterContract = new ethers.Contract(
addresses.Greeter,
GreeterArtifact.abi,
aaSigner
);
// greeter contract greet calldata
const greetCallData = GreeterContract.interface.encodeFunctionData(
"greet",
[]
);
/*
* @params functionCalldata: bytes, walletAddress: string, address: string, value: double
* @return transaction hash
* @nature async
*/
const txn = await bananaInstance.execute(greetCallData, Greeter.address, amount)
If you have any questions please post them Banana SDK Discord forum.
Last updated