区块链
pluginagentmarketplace2026-10-27查看 828复制 1224
区块链开发技能——智能合约、DeFi、Web3、共识
📘如何使用这个技能
- 1复制技能内容·点击上方「Copy SKILL.md」复制全部内容,或 Download 下载到本地
- 2打开你的 AI 客户端·支持 Claude Code、Trae、Cursor、ChatGPT、DeepSeek、Kimi 等任意 AI 助手
- 3粘贴为系统提示/知识文件·Claude Code:放入 .claude/skills/ 目录;普通对话:作为首条消息发送并说「请严格按这份技能文档执行」
- 4直接提出你的需求·AI 会按技能定义的工作流、格式和约束来处理,无需再解释背景
💡 提示:技能生效后,每次对话只需一句需求,AI 会按 SKILL.md 的流程执行。
SKILL.md3354 chars
---
name: blockchain
description: Blockchain development skill - Smart contracts, DeFi, Web3, consensus
version: "1.0.0"
sasmp_version: "1.3.0"
input_schema:
type: object
properties:
task: { type: string, enum: [develop, audit, deploy, optimize, integrate] }
platform: { type: string, enum: [ethereum, solana, polygon, arbitrum, base] }
required: [task]
output_schema:
type: object
properties:
contract: { type: string }
audit_report: { type: object }
gas_analysis: { type: object }
retry_config:
max_attempts: 3
backoff: exponential
timeout_ms: 120000
---
# Blockchain Development Skill
## PURPOSE
Smart contract development, DeFi protocols, and Web3 integration.
## CORE COMPETENCIES
```
Smart Contracts:
├── Solidity (EVM)
├── Rust (Solana)
├── Move (Sui/Aptos)
├── Security patterns
└── Upgradability
DeFi Protocols:
├── AMM/DEX
├── Lending/Borrowing
├── Yield farming
├── Staking
└── Oracles (Chainlink)
Web3 Integration:
├── ethers.js / viem
├── Wallet connection
├── Transaction handling
├── Event listening
└── IPFS/Arweave
```
## CODE PATTERNS
### Solidity Contract
```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
contract SecureVault is ReentrancyGuard, Ownable {
mapping(address => uint256) private balances;
event Deposited(address indexed user, uint256 amount);
event Withdrawn(address indexed user, uint256 amount);
function deposit() external payable nonReentrant {
require(msg.value > 0, "Amount must be > 0");
balances[msg.sender] += msg.value;
emit Deposited(msg.sender, msg.value);
}
function withdraw(uint256 amount) external nonReentrant {
require(balances[msg.sender] >= amount, "Insufficient balance");
balances[msg.sender] -= amount;
(bool success, ) = msg.sender.call{value: amount}("");
require(success, "Transfer failed");
emit Withdrawn(msg.sender, amount);
}
}
```
### Web3 Integration
```typescript
import { createPublicClient, createWalletClient, http } from 'viem';
import { mainnet } from 'viem/chains';
const publicClient = createPublicClient({
chain: mainnet,
transport: http(),
});
// Read contract
const balance = await publicClient.readContract({
address: contractAddress,
abi: vaultABI,
functionName: 'balanceOf',
args: [userAddress],
});
// Write contract
const hash = await walletClient.writeContract({
address: contractAddress,
abi: vaultABI,
functionName: 'deposit',
value: parseEther('1'),
});
```
## SECURITY CHECKLIST
```
[ ] Reentrancy protection
[ ] Integer overflow (use 0.8+)
[ ] Access control
[ ] Input validation
[ ] Check-effects-interactions pattern
[ ] Slippage protection
[ ] Oracle manipulation resistance
[ ] Flash loan attack prevention
[ ] Upgrade security (timelock)
[ ] Emergency pause mechanism
```
## TROUBLESHOOTING
| Issue | Cause | Solution |
|-------|-------|----------|
| Reentrancy | External call before state update | Use ReentrancyGuard |
| Front-running | Public mempool | Use commit-reveal |
| Oracle manipulation | Single source | Multiple oracles, TWAP |
| High gas | Inefficient storage | Pack structs, use events |