web3-frontend by pluginagentmarketplace/custom-plugin-blockchain
npx skills add https://github.com/pluginagentmarketplace/custom-plugin-blockchain --skill web3-frontend掌握 Web3 前端开发,包括钱包集成、现代库(viem/wagmi)和生产级 dApp 模式。
# 调用此技能进行 Web3 前端开发
Skill("web3-frontend", topic="wallet", framework="react")
连接用户到 Web3:
处理区块链交互:
验证用户身份:
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
使用 wagmi 的现代模式:
'use client';
import { ConnectButton } from '@rainbow-me/rainbowkit';
import { useAccount } from 'wagmi';
export function WalletConnect() {
const { address, isConnected } = useAccount();
return (
<div>
<ConnectButton />
{isConnected && <p>已连接: {address}</p>}
</div>
);
}
import { useWriteContract, useWaitForTransactionReceipt } from 'wagmi';
import { parseEther } from 'viem';
export function MintButton() {
const { writeContract, data: hash, isPending } = useWriteContract();
const { isLoading, isSuccess } = useWaitForTransactionReceipt({ hash });
const mint = () => {
writeContract({
address: '0x...',
abi: [...],
functionName: 'mint',
args: [1n],
value: parseEther('0.08'),
});
};
return (
<button onClick={mint} disabled={isPending || isLoading}>
{isPending ? '请在钱包中确认...' :
isLoading ? '铸造中...' :
isSuccess ? '已铸造!' : '铸造 NFT'}
</button>
);
}
import { useSignTypedData } from 'wagmi';
const DOMAIN = {
name: '我的应用',
version: '1',
chainId: 1,
verifyingContract: '0x...',
};
export function useSignOrder() {
const { signTypedDataAsync } = useSignTypedData();
const sign = async (order: Order) => {
return await signTypedDataAsync({
domain: DOMAIN,
types: { Order: [...] },
primaryType: 'Order',
message: order,
});
};
return { sign };
}
export function parseError(error: unknown): string {
const msg = error instanceof Error ? error.message : String(error);
if (msg.includes('user rejected')) return '交易已取消';
if (msg.includes('insufficient funds')) return '余额不足';
if (msg.includes('execution reverted')) {
const reason = msg.match(/reason="([^"]+)"/)?.[1];
return reason || '交易将失败';
}
return '交易失败';
}
npm install wagmi viem @rainbow-me/rainbowkit @tanstack/react-query
// providers/Web3.tsx
import { WagmiProvider } from 'wagmi';
import { RainbowKitProvider } from '@rainbow-me/rainbowkit';
import { QueryClientProvider, QueryClient } from '@tanstack/react-query';
import { config } from './config';
const queryClient = new QueryClient();
export function Web3Provider({ children }) {
return (
<WagmiProvider config={config}>
<QueryClientProvider client={queryClient}>
<RainbowKitProvider>{children}</RainbowKitProvider>
</QueryClientProvider>
</WagmiProvider>
);
}
| 模式 | 使用场景 | Hook |
|---|---|---|
| 连接钱包 | 用户认证 | useAccount |
| 读取数据 | 显示余额 | useReadContract |
| 写入交易 | 铸造、转账 | useWriteContract |
| 等待交易 | 确认状态 | useWaitForTransactionReceipt |
| 签名消息 | 认证、许可 | useSignMessage |
| 陷阱 | 问题 | 解决方案 |
|---|---|---|
| Hydration 错误 | SSR 不匹配 | 使用 dynamic 并设置 ssr: false |
| BigInt 序列化 | JSON.stringify | 自定义序列化器 |
| 数据过时 | 缓存问题 | 使用 refetchInterval |
// 确保仅在客户端运行
import dynamic from 'next/dynamic';
const ConnectButton = dynamic(
() => import('./ConnectButton'),
{ ssr: false }
);
检查 Gas 设置或加速交易:
await wallet.sendTransaction({
...tx,
maxFeePerGas: tx.maxFeePerGas * 120n / 100n,
});
05-web3-frontendethereum-development, solidity-development| 版本 | 日期 | 变更 |
|---|---|---|
| 2.0.0 | 2025-01 | 生产级,支持 wagmi v2, viem |
| 1.0.0 | 2024-12 | 初始版本 |
每周安装量
136
代码仓库
GitHub 星标数
1
首次出现
2026年1月21日
安全审计
安装于
opencode108
codex100
gemini-cli97
github-copilot87
cursor81
claude-code79
Master Web3 frontend development with wallet integration, modern libraries (viem/wagmi), and production dApp patterns.
# Invoke this skill for Web3 frontend development
Skill("web3-frontend", topic="wallet", framework="react")
Connect users to Web3:
Handle blockchain interactions:
Verify user identity:
Modern patterns with wagmi:
'use client';
import { ConnectButton } from '@rainbow-me/rainbowkit';
import { useAccount } from 'wagmi';
export function WalletConnect() {
const { address, isConnected } = useAccount();
return (
<div>
<ConnectButton />
{isConnected && <p>Connected: {address}</p>}
</div>
);
}
import { useWriteContract, useWaitForTransactionReceipt } from 'wagmi';
import { parseEther } from 'viem';
export function MintButton() {
const { writeContract, data: hash, isPending } = useWriteContract();
const { isLoading, isSuccess } = useWaitForTransactionReceipt({ hash });
const mint = () => {
writeContract({
address: '0x...',
abi: [...],
functionName: 'mint',
args: [1n],
value: parseEther('0.08'),
});
};
return (
<button onClick={mint} disabled={isPending || isLoading}>
{isPending ? 'Confirm in wallet...' :
isLoading ? 'Minting...' :
isSuccess ? 'Minted!' : 'Mint NFT'}
</button>
);
}
import { useSignTypedData } from 'wagmi';
const DOMAIN = {
name: 'My App',
version: '1',
chainId: 1,
verifyingContract: '0x...',
};
export function useSignOrder() {
const { signTypedDataAsync } = useSignTypedData();
const sign = async (order: Order) => {
return await signTypedDataAsync({
domain: DOMAIN,
types: { Order: [...] },
primaryType: 'Order',
message: order,
});
};
return { sign };
}
export function parseError(error: unknown): string {
const msg = error instanceof Error ? error.message : String(error);
if (msg.includes('user rejected')) return 'Transaction cancelled';
if (msg.includes('insufficient funds')) return 'Insufficient balance';
if (msg.includes('execution reverted')) {
const reason = msg.match(/reason="([^"]+)"/)?.[1];
return reason || 'Transaction would fail';
}
return 'Transaction failed';
}
npm install wagmi viem @rainbow-me/rainbowkit @tanstack/react-query
// providers/Web3.tsx
import { WagmiProvider } from 'wagmi';
import { RainbowKitProvider } from '@rainbow-me/rainbowkit';
import { QueryClientProvider, QueryClient } from '@tanstack/react-query';
import { config } from './config';
const queryClient = new QueryClient();
export function Web3Provider({ children }) {
return (
<WagmiProvider config={config}>
<QueryClientProvider client={queryClient}>
<RainbowKitProvider>{children}</RainbowKitProvider>
</QueryClientProvider>
</WagmiProvider>
);
}
| Pattern | Use Case | Hook |
|---|---|---|
| Connect wallet | User auth | useAccount |
| Read data | Display balances | useReadContract |
| Write tx | Mint, transfer | useWriteContract |
| Wait for tx | Confirm state | useWaitForTransactionReceipt |
| Sign message | Auth, permit | useSignMessage |
| Pitfall | Issue | Solution |
|---|---|---|
| Hydration error | SSR mismatch | Use dynamic with ssr: false |
| BigInt serialization | JSON.stringify | Custom serializer |
| Stale data | Cache issues | Use refetchInterval |
// Ensure client-side only
import dynamic from 'next/dynamic';
const ConnectButton = dynamic(
() => import('./ConnectButton'),
{ ssr: false }
);
Check gas settings or speed up:
await wallet.sendTransaction({
...tx,
maxFeePerGas: tx.maxFeePerGas * 120n / 100n,
});
05-web3-frontendethereum-development, solidity-development| Version | Date | Changes |
|---|---|---|
| 2.0.0 | 2025-01 | Production-grade with wagmi v2, viem |
| 1.0.0 | 2024-12 | Initial release |
Weekly Installs
136
Repository
GitHub Stars
1
First Seen
Jan 21, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
opencode108
codex100
gemini-cli97
github-copilot87
cursor81
claude-code79
FluxA Agent Wallet:AI代理安全支付钱包,支持USDC转账与x402支付
7,600 周安装