1.2.8 • Published 5 months ago

multi-wallet-connector v1.2.8

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

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);
1.2.8

5 months ago

1.2.7

5 months ago

1.2.6

5 months ago

1.2.5

5 months ago

1.2.4

5 months ago

1.2.3

5 months ago

1.2.2

5 months ago

1.2.0

11 months ago

1.2.1

11 months ago

1.0.36

1 year ago

1.0.35

1 year ago

1.0.33

1 year ago

1.0.32

1 year ago

1.0.31

1 year ago

1.0.30

1 year ago

1.0.29

1 year ago

1.0.28

1 year ago

1.0.27

1 year ago

1.0.26

1 year ago

1.0.25

1 year ago

1.0.24

1 year ago

1.0.23

1 year ago

1.0.22

1 year ago

1.0.21

1 year ago

1.0.20

1 year ago

1.0.19

1 year ago

1.0.18

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago