npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@banana-wallet/adapter

v1.1.9

Published

Banana Wallet Web Adapter

Readme

Banana Wallet Web Adapter

https://bananawallet.io/

npm i @banana-wallet/adapter
yarn add @banana-wallet/adapter

Import

import { connect } from '@banana-wallet/adapter';

Connect

const bananaWallet = await connect();

Connect using React Hooks

import { useConnection } from '@banana-wallet/adapter/src/hooks';

const App = () => {
  const bananaWallet = useConnection();
  // ...
}

Check if your visitor has Banana Wallet

import { checkIsAvailable } from '@banana-wallet/adapter';

const checkIsBananaWalletAvailable = async () => {
  const isBananaWalletAvailable = await checkIsAvailable();
  console.log({ isBananaWalletAvailable });
}
checkIsBananaWalletAvailable();

Custom cluster / environment

const bananaWallet = await connect({
    cluster: 'devnet' // 'mainnet-beta' | 'testnet' | 'devnet'
});

Simple React example

import React, { useCallback } from 'react';
import { useConnection } from '@banana-wallet/adapter/src/hooks';

const App = () => {
  const bananaWallet = useConnection();
  const handleClick = useCallback(async () => {
    const props = {
      action: {
        type: 'click',
        value: '$0.1'
      },
      toPubkey: 'A7vY2TUrQ6Jv4iTgn2fqWit8pcWWiEaRVnrrwRrA9uBK',
    };
    await bananaWallet.charge(props);
  }, [bananaWallet]);

  return (
    <input
      type='button'
      onClick={handleClick}
      value='Click [$0.1]'
    />
  )
}

Simple vanilla example

import { connect } from '@banana-wallet/adapter';

const initBanana = async () => {
  const bananaWallet = await connect();
  const props = {
    action: {
      type: 'click',
      value: '$0.1'
    },
    toPubkey: 'A7vY2TUrQ6Jv4iTgn2fqWit8pcWWiEaRVnrrwRrA9uBK',
  };
  const isApproved = await bananaWallet.approve(props);
  if (!isApproved) {
    console.log('charge request has been denied, we cannot continue...')
    return;
  }
  // add some custom click action
  document.addEventListener('click', async () => {
    await bananaWallet.charge(props);
  });
}
initBanana();

Read Public Key

const { publicKey } = bananaWallet.publicData;

Charge user per click

const props = {
  action: {
    type: 'click',
    value: '$1'
  },
  toPubkey: 'A7vY2TUrQ6Jv4iTgn2fqWit8pcWWiEaRVnrrwRrA9uBK',
};

bananaWallet.charge(props);

Charge user per minute

const props = {
  action: {
    type: 'interval',
    value: '$0.1',
    interval: 60*1000 // [ms], so it's 1 minute
    // supported values: 1000 to 59000, 60*1000 (1 minute), 60*60*1000 (1 hour), 24*60*60*1000 (1 day)
  },
  toPubkey: 'A7vY2TUrQ6Jv4iTgn2fqWit8pcWWiEaRVnrrwRrA9uBK',
};

bananaWallet.charge(props);

Charge user per page scroll

const props = {
  action: {
    type: 'payPerScroll',
    value: '$1',
    checkpoints: 4 // = per 25% scroll
  },
  toPubkey: 'A7vY2TUrQ6Jv4iTgn2fqWit8pcWWiEaRVnrrwRrA9uBK',
};

bananaWallet.charge(props);

Pre-approved actions

You can ask the user for a permission before the action really happens, eg. in sign-up process

const props = {
  action: {
    type: 'click',
    value: '$1'
  },
  toPubkey: 'A7vY2TUrQ6Jv4iTgn2fqWit8pcWWiEaRVnrrwRrA9uBK',
};

bananaWallet.approve(props);
// ... now you can use banana.charge(props) anytime

Detect if charge was approved

const chargeUser = async () => {
  const props = {
    action: {
      type: 'click',
      value: '$1'
    },
    toPubkey: 'A7vY2TUrQ6Jv4iTgn2fqWit8pcWWiEaRVnrrwRrA9uBK',
  };

  const isApproved = await bananaWallet.approve(props);
  if (isApproved) {
    bananaWallet.charge(props);
  }
}

chargeUser();

Check if an action was already approved some time ago

const props = {
  action: {
    type: 'click',
    value: '$1'
  },
  toPubkey: 'A7vY2TUrQ6Jv4iTgn2fqWit8pcWWiEaRVnrrwRrA9uBK',
};

const isApproved = await bananaWallet.isApproved(props);

Show Banana Wallet - dialog window

bananaWallet.showDialog();

Hide dialog window

bananaWallet.hideDialog();

Clear approvals

Useful method for development environment

bananaWallet.request({
  method: 'wallet_clearApprovals',
  params: {}
});

Listen for transaction signatures

document.addEventListener('walletChargeRequestSigned', (data) => {
  const { props, signature } = data?.detail;
  console.log('received', { signature }, 'for a request with props', { props })
});

Send a transaction

bananaWallet.sendTransaction({
  transaction
});

sendTransaction example

const transaction = new Transaction().add(
      SystemProgram.transfer({
        fromPubkey: bananaWallet.publicData.publicKey,
        toPubkey: new PublicKey('A7vY2TUrQ6Jv4iTgn2fqWit8pcWWiEaRVnrrwRrA9uBK'),
        lamports: 1001,
      }),
);

const { signature } = await bananaWallet.sendTransaction({
  transaction
});
console.log({ signature })

Sign a message

Use this method to verify the ownership of the publicKey

// required
npm i tweetnacl
import nacl from 'tweetnacl';

const messageString = `Verify my public key`;
const message = new TextEncoder().encode(messageString);
const signature = await bananaWallet.signMessage({ message });
const publicKeyEncoded = bananaWallet.publicData.publicKey.toBytes();
const isSignatureValid = nacl.sign.detached.verify(message, signature, publicKeyEncoded)
console.log({
  isSignatureValid
})