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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@web3jskit/walletkit

v0.4.6

Published

walletkit

Downloads

70

Readme

WalletKit

WalletKit 是一个轻量级的多链钱包连接工具包,旨在帮助开发者快速集成支持多条链的钱包插件,如 MetaMask、Phantom、TronLink、Gel Wallet 等。它提供了便捷的状态管理、自定义 Hooks 和统一的 API,使 DApp 开发更简单高效。

WalletKit is a lightweight, multi-chain compatible wallet connection toolkit designed to help developers quickly integrate wallet plugins that support multiple chains, such as MetaMask, Phantom, TronLink, Gel Wallet, and more. It provides convenient state management, custom hooks, and a unified API, making DApp development simpler and more efficient.

架构 Architecture

WalletKit 由两个主要部分组成 / WalletKit consists of two main parts:

  1. @web3jskit/wallethelper: 底层钱包连接库,提供统一的钱包接口和状态管理 / Core wallet connection library providing unified wallet interfaces and state management

    • 多链支持 / Multi-chain support (EVM, PUT, SOL, Tron, BTC)
    • 钱包检测和连接 / Wallet detection and connection
    • 统一的交易接口 / Unified transaction interface
    • 状态管理 / State management
  2. @web3jskit/walletkit: React 组件库,提供开箱即用的 UI 组件 / React component library providing ready-to-use UI components

    • 钱包连接按钮 / Wallet connection button
    • 钱包选择模态框 / Wallet selection modal
    • 链切换组件 / Chain switching component
    • 自定义 Hooks / Custom hooks

安装 Installation

通过 npm、yarn 或 pnpm 安装 / Install via npm, yarn, or pnpm:

# npm
npm install @web3jskit/walletkit

# yarn
yarn add @web3jskit/walletkit

# pnpm
pnpm add @web3jskit/walletkit

快速开始 Quick Start

1. 导入并初始化 Import and Initialize

import { WalletKitProvider, ConnectButton } from '@web3jskit/walletkit';

function App() {
	return (
		<WalletKitProvider>
			<ConnectButton />
			{/* 其他组件 Other components */}
		</WalletKitProvider>
	);
}

2. 使用 Hooks Use Hooks

import { useWalletKit } from '@web3jskit/walletkit';

function MyComponent() {
	const { openModal, currentChainType, setChainType, currentConnector, walletAddress, getProvider } = useWalletKit();

	// 连接钱包 Connect wallet
	const handleConnect = () => {
		openModal(AppModal.ConnectModal);
	};

	// 断开连接 Disconnect
	const handleDisconnect = () => {
		currentConnector?.disconnect();
	};

	return (
		<div>
			<div>Chain: {currentChainType}</div>
			<div>Wallet: {currentConnector?.name}</div>
			<div>Address: {walletAddress}</div>
		</div>
	);
}

核心功能 Core Features

1. 钱包连接 Wallet Connection

const { currentConnector, connectStatus } = useWalletKit();

// 连接钱包 Connect wallet
await currentConnector.connect();

// 断开连接 Disconnect
await currentConnector.disconnect();

// 监听状态 Listen to status
console.log(connectStatus); // 'connected' | 'connecting' | 'disconnected'

2. 链切换 Chain Switching

const { setChainType, currentChainType } = useWalletKit();

// 切换链 Switch chain
await setChainType(ChainType.EVM);

3. 交易操作 Transaction Operations

const { currentConnector } = useWalletKit();

// 签名消息 Sign message
const signature = await currentConnector.signMessage('Hello Web3');

// 发送交易 Send transaction
const txHash = await currentConnector.sendTransaction({
 to: '0x...',
 value: '0x...',
});

// 合约调用 Contract call
const result = await currentConnector.writeContract({
 address: '0x...',
 abi: [...],
 functionName: 'transfer',
 args: [...],
});

支持的钱包 Supported Wallets

  • MetaMask (EVM)
  • Phantom (SOL, BTC)
  • TronLink (TRON)
  • Gel Wallet (EVM, PUT, SOL)
  • OKX Wallet (EVM)
  • Trust Wallet (EVM)
  • TokenPocket (EVM)
  • Bitget Wallet (EVM)
  • Coinbase Wallet (EVM)

API 参考 API Reference

useWalletKit Hook

| 属性/方法 Property/Method | 描述 Description | | ------------------------- | --------------------------------------- | | currentChainType | 当前链类型 Current chain type | | setChainType | 切换链类型 Switch chain type | | currentConnector | 当前钱包连接器 Current wallet connector | | connectStatus | 连接状态 Connection status | | walletAddress | 钱包地址 Wallet address | | getProvider | 获取 Provider Get provider | | openModal | 打开模态框 Open modal | | closeModal | 关闭模态框 Close modal |

WalletConnector

| 方法 Method | 描述 Description | | ----------------------- | ------------------------- | | connect() | 连接钱包 Connect wallet | | disconnect() | 断开连接 Disconnect | | signMessage(message) | 签名消息 Sign message | | sendTransaction(tx) | 发送交易 Send transaction | | writeContract(params) | 合约写入 Write contract | | readContract(params) | 合约读取 Read contract |

贡献指南 Contributing

欢迎提交 Issues 和功能请求!贡献步骤:

We welcome issues and feature requests! Steps to contribute:

  1. Fork 本仓库 Fork this repository
  2. 创建功能分支 Create feature branch:
git checkout -b feature/my-feature
  1. 提交更改 Commit changes:
git commit -m "Add some feature"
  1. 推送分支 Push branch:
git push origin feature/my-feature
  1. 提交 Pull Request Submit Pull Request

许可证 License

MIT License

联系我们 Contact Us

如有问题或建议,请通过以下方式联系我们:

For questions or suggestions, please contact us:

希望你喜欢使用 WalletKit!

Hope you enjoy using WalletKit! 😊