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 🙏

© 2024 – Pkg Stats / Ryan Hefner

multi-wallet-connector

v1.2.1

Published

A multi-wallet-connector class for managing wallet connection states

Downloads

311

Readme

MultiWallet

A simple singleton class for managing wallet connection states in React applications.

Table of Contents

Introduction

multi-wallet-connector is a JavaScript library that simplifies connecting to multiple cryptocurrency wallets such as MetaMask, Phantom, and XWallet. It provides an easy-to-use interface for handling wallet connections and state management, allowing developers to integrate wallet functionalities seamlessly into their applications.

Features

  • Support for Multiple Wallets: Connect to MetaMask, Phantom, and XWallet effortlessly.
  • State Management: Centralized management of wallet states, such as connection status and active wallet address.
  • Singleton Pattern: Ensures a single instance of wallet management across the application.
  • Easy Integration: Simple API for integration with existing web applications.

Installation

You can install the multi-wallet-connector package via npm:

npm install multi-wallet-connector
import MultiWallet from 'multi-wallet-connector'

API Documentation

Checking Wallet Installation

const isMetamaskInstalled = MultiWallet.isWalletInstalled("Metamask");
const isPhantomInstalled = MultiWallet.isWalletInstalled("Phantom");
const isXWalletInstalled = MultiWallet.isWalletInstalled("XWallet");

Checking Wallet Connection Status

const isAnyWalletConnected = MultiWallet.isAnyWalletConnected();
const isMetamaskActive = MultiWallet.isMetamaskActive();
const isPhantomActive = MultiWallet.isPhantomActive();
const isXwalletActive = MultiWallet.isXwalletActive();

Get Active Address

 const address = MultiWallet.getActiveAddress();

Setting and Getting RPC Endpoints

MultiWallet.setL1xRpc(rpc);
MultiWallet.setSolanaRpc(rpc);
const l1xRpc = MultiWallet.getL1xRpc();
const solanaRpc = MultiWallet.getSolanaRpc();

Connecting to Wallets

const connnection = await MultiWallet.connectWallet(walletName, message);

Getting Balances for Connected Wallets

const balance = await MultiWallet.getBalance(functionName, tokenAddress, walletAddress, rpc);
const evmBalance = await MultiWallet.getBalance("getEVMNativeBalance", "", walletAddress, rpc);
const solanaTokenBalance = await MultiWallet.getBalance("getSolanaTokenBalance", tokenAddress, walletAddress, rpc);
const l1xBalance = await MultiWallet.getBalance("getL1xNativeBalance", "", walletAddress, rpc);
const solanaTokenBalance = await MultiWallet.getBalance("getSolanaTokenBalance", tokenAddress, walletAddress, rpc);

EXAMPLE

Check if MetaMask is Installed

const isInstalled = MultiWallet.isWalletInstalled("Metamask");

Connect to Phantom Wallet

  const result = await MultiWallet.connectWallet("Phantom", "Please sign this message.");

Get Balances

  const balance = await MultiWallet.getBalance("getEVMNativeBalance", "", walletAddress, rpc);
  const balance = await MultiWallet.getBalance("getEVMTokenBalance", tokenAddress, walletAddress, rpc);
  const balance = await MultiWallet.getBalance("getL1xNativeBalance", "", walletAddress, rpc);
  const balance = await MultiWallet.getBalance("getSolanaNativeBalance", "", walletAddress, rpc);
  const balance = await MultiWallet.getBalance("getSolanaTokenBalance", tokenAddress, walletAddress, rpc);