Usage of Passkey Manager for Integration with Wallet SDK

The below example demonstrates the usage for creating a wallet and making transactions using it.

Let's begin with importing the necessary modules which would be required for instantiating wallet and creating transactions with it.

import { Banana, Chains } from '@bananahq/react-native-sdk';

Once modules importing you'll have to create a Deepllink for your app.


Creating an instance of Banana module with chain and Deeplink to start using the method offered by Banana SDK.

const bananaInstance = new Banana(Chains.mumbai, APP_DEEPLINK);

Now let's create / connect wallet.

// checking if wallet already exists
const name = await bananaInstance.getWalletName();

let walletInstance, walletAddress;

if (name) {
  // directly connecting wallet using the wallet name if wallet already exist
  walletInstance = await bananaInstance.connectWallet(name);
  walletAddress = await walletInstance.getAddress();
} else {
  // creating new wallet.
  walletInstance = await bananaInstance.createWallet();
  walletAddress = await walletInstance.getAddress();

For making transactions from the wallet created we'll have to extract out signer from it and once signer is extracted we can use it's sendTransaction method to make transactions.

const signer = await walletInstance.getSigner();

Now let's create and send a transaction.

// sample abi for encoding transaction
const abi = [
    inputs: [],
    name: "returnStake",
    outputs: [],
    stateMutability: "nonpayable",
    type: "function",
    inputs: [],
    name: "stake",
    outputs: [],
    stateMutability: "payable",
    type: "function",

// extracting signer from the wallet
const signer = walletInstance.getSigner();

// sample contract whose stake function we would invoke
const stakeAddress = "0x8b370128A84bc2Df7fF4813675e294b1ae816178";

// creating transaction for the stake function
const tx = {
  gasLimit: "0x55555",
  to: stakeAddress,
  value: ethers.utils.parseEther("100"),
  data: new ethers.utils.Interface(abi).encodeFunctionData("stake", []),

// sending the transaction
const txn = await signer.sendTransaction(tx); 

If you have any questions, please feel free to ask on the Banana SDK Discord forum.

Last updated