用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/mikailustuner/OmniRule --skill web3-patterns命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | web3-patterns |
| description | Wallet connections, smart contract integration, IPFS storage, and blockchain patterns for Web3 applications. |
| triggers | {"keywords":["web3","blockchain","ethereum","smart contract","wallet","NFT","ethers","wagmi","viem"]} |
| auto_load_when | Building Web3 or blockchain integrations |
| agent | architect |
| tools | ["Read","Write","Bash"] |
Wallet selection:
├── MetaMask: Most popular, browser extension
├── WalletConnect: Mobile-friendly, QR code
├── Coinbase Wallet: Mainstream users
├── Rainbow: Mobile-native
└── Injected: Multiple injected providers
Connection flow:
1. Detect provider (window.ethereum)
2. Request accounts (eth_requestAccounts)
3. Check chain (eth_chainId)
4. Switch chains if needed
5. Store connection state
6. Listen for changes (accountsChanged, chainChanged)
Use EVM chains when:
├── Ethereum ecosystem tools
├── DeFi/AMM integration
├── Largest user base
└── Most documentation
Use Solana when:
├── High throughput needed
├── Lower transaction costs
├── Mobile-first users
└── Different tech stack
Use multi-chain when:
├── Cross-chain dApps
├── Different user bases
└── Bridge requirements
Contract interaction:
├── Read: view/pure functions (free)
├── Write: state-changing (gas needed)
├── Events: Historical data, logs
└── Multicall: Batch read calls
Library choice:
├── ethers.js: Lightweight, popular
├── viem: Modern, type-safe, lightweight
├── web3.js: Legacy, feature-rich
└── wagmi: React hooks, composable
Gas optimization:
├── Batch calls: Multicall pattern
├── Storage packing: Pack struct fields
├── Events: Index events for filtering
└── Lazy evaluation: Only compute on-chain
Security:
├── Never trust user input
├── Reentrancy guards when needed
├── Access control (Ownable, Roles)
└── Upgradeable pattern for logic
When to use IPFS:
├── Immutable content (verified)
├── Large files (decentralized storage)
├── NFT metadata
└── Decentralized data sharing
Alternatives:
├── Arweave: Permanent storage
├── Filecoin: Incentivized storage
├── Pinata/Infura: Pinning service
└── Web3.storage: Simple API
Pattern:
├── Upload: IPFS -> get CID -> store CID
├── Retrieve: Use CID -> gateway or local node
└── Content addressing: Always verify hash
Token standards:
├── ERC-20: Fungible tokens
├── ERC-721: NFTs (single)
├── ERC-1155: Multi-token (games,批量)
└── ERC-4626: Tokenized vaults
Token integration:
├── Read balance: token.balanceOf(address)
├── Transfer: token.transfer(to, amount)
├── Approve: token.approve(spender, amount)
└── Allowance: token.allowance(owner, spender)
Reading blockchain data:
├── Direct RPC: Fast, but no history
├── The Graph: Indexed data (subgraphs)
├── Alchemy/Infura: APIs, history
└── Events: Past logs for history
Storage patterns:
├── On-chain: Immutable, expensive
├── IPFS: Content-addressed, mutable
├── Off-chain: Centralized, fast
└── Hybrid: IPFS CID on-chain
UX patterns:
├── Auto-connect: Remember last wallet
├── Chain switching: Prompt to switch
├── Gas estimation: Show before confirm
├── Pending states: Transaction pending
└── Error handling: Clear error messages
Transaction patterns:
├── Nonce management: Track pending
├── Speed up: Replace with higher gas
└── Cancel: Replace with 0 value
❌ Trusting client-side wallet data without on-chain verification
✅ Always verify signatures and ownership on-chain / server-side
❌ Sending transactions without estimating gas
✅ estimateGas() before every transaction; add 20% buffer
❌ Storing private keys in code or .env
✅ Hardware wallet / KMS for production; never commit keys
❌ No re-entrancy guard on contract functions
✅ nonReentrant modifier (OpenZeppelin) on all state-changing functions
❌ Contract with no upgrade path
✅ Proxy pattern or design for immutability intentionally
| Task | Library | Note |
|---|---|---|
| Wallet connect | wagmi + ConnectKit | React hooks |
| Read contract | ethers.js / viem | Static call |
| Write contract | wagmi writeContract | Gas estimate first |
| Sign message | signMessage (SIWE) | Auth pattern |
| IPFS storage | Pinata / web3.storage | Off-chain metadata |
| Contract testing | Hardhat / Foundry | Fork mainnet for integration |