Fantasy Top 是一个基于 Monad 测试网 构建的去中心化 NFT 卡牌交易系统,灵感来源于炉石传说等知名卡牌游戏。系统支持卡包购买、NFT 卡牌交易、竞拍等完整的区块链游戏生态。
- 🔓 无限制访问 - 任何钱包地址都可以登录使用
- 🎲 公平随机 - 基于区块链的真随机数生成
- 🏪 去中心化交易 - 完全基于智能合约的 P2P 交易
- 💎 稀有度系统 - 四级稀有度分布机制
- 🌐 多钱包支持 - 兼容 MetaMask、OKX Wallet 等主流钱包
| 功能 | 链接 | 描述 |
|---|---|---|
| 🎮 主应用 | http://localhost:3000 | 完整的 NFT 交易系统 |
| 🔧 调试页面 | http://localhost:3000/debug.html | 钱包连接测试 |
| 🧪 兼容性测试 | http://localhost:3000/test.html | 多钱包兼容性验证 |
| 👥 多用户演示 | http://localhost:3000/access.html | 展示无限制访问特性 |
| 合约 | 地址 | 功能 |
|---|---|---|
| FantasyCard | 0xe8c3437119573cE3D8F73Ea76f2D30A26322f257 |
ERC721 NFT 卡牌合约 |
| CardPack | 0x1fF37d2816d65CA519ba66b754F7dD94a58C2972 |
卡包购买与开启 |
| FantasyMarketplace | 0x47F741F5c512Dd73A72568f2Fa03f89E25342365 |
去中心化交易市场 |
- 网络名称: Monad Testnet
- Chain ID: 10143
- 货币符号: MON
- RPC URL: https://testnet-rpc.monad.xyz
- 区块浏览器: https://testnet.monadexplorer.com
- Node.js 16.0+
- npm 或 yarn
- Git
- MetaMask 或 OKX Wallet
# 克隆项目
git clone <repository-url>
cd MonadChogCard
# 安装依赖
npm install
# 启动系统
./start.sh# 1. 安装依赖
npm install
# 2. 编译合约
npx hardhat compile
# 3. 部署到 Monad 测试网
npx hardhat run scripts/deploy.js --network monad-testnet
# 4. 启动前端
cd frontend && npm run dev- 访问 Monad 测试网水龙头
- 输入您的钱包地址
- 获取 MON 测试币
- 价格: 0.01 MON = 10 张随机 NFT 卡牌
- 即时开启: 购买后立即获得卡牌
- 公平分布: 基于区块哈希的真随机数
| 稀有度 | 概率 | 颜色标识 | 属性加成 |
|---|---|---|---|
| 🔵 普通 | 60% | 灰色边框 | 基础属性 |
| 🟣 稀有 | 29% | 蓝色边框 | 属性提升 40% |
| 🟠 史诗 | 10% | 紫色边框 | 属性提升 70% |
| 🟡 传奇 | 1% | 金色边框 | 属性提升 90% |
- 直接销售 - 固定价格即时交易
- 竞拍系统 - 出价竞争获得 NFT
- 历史记录 - 完整的链上交易追踪
- 价格发现 - 市场驱动的价格机制
- 市场手续费: 2.5%
- Gas 费用: 由 Monad 网络决定
- 无隐藏费用: 所有费用透明公开
{
"attack": "1-10", // 攻击力
"health": "1-10", // 生命值
"cost": "1-12", // 法力消耗
"rarity": "0-3", // 稀有度等级
"cardType": "0-2", // 卡牌类型
"dna": "uint256", // 唯一标识符
"name": "string", // 卡牌名称
"description": "string" // 卡牌描述
}- 🗡️ 随从 - 战场上的战斗单位
- ✨ 法术 - 一次性效果法术
- ⚔️ 武器 - 增强战斗能力
MonadChogCard/
├── contracts/ # 智能合约
│ ├── FantasyCard.sol # ERC721 NFT 合约
│ ├── CardPack.sol # 卡包系统合约
│ └── FantasyMarketplace.sol # 交易市场合约
├── frontend/ # 前端应用
│ ├── public/
│ │ ├── index.html # 主页面
│ │ ├── app.js # 核心逻辑
│ │ ├── style.css # 样式文件
│ │ ├── debug.html # 调试页面
│ │ ├── test.html # 测试页面
│ │ └── access.html # 多用户演示
│ └── package.json
├── scripts/ # 部署脚本
│ ├── deploy.js # 合约部署
│ ├── status.js # 系统状态查询
│ ├── interact.js # 合约交互演示
│ └── multi-user-test.js # 多用户测试
├── test/ # 测试文件
│ └── FantasyTop.test.js # 合约单元测试
├── hardhat.config.js # Hardhat 配置
├── package.json # 项目依赖
└── README.md # 项目文档
- Solidity 0.8.20 - 合约开发语言
- OpenZeppelin - 安全的合约库
- Hardhat - 开发框架
- Ethers.js v6 - 区块链交互库
- Vanilla JavaScript - 纯 JavaScript 实现
- HTML5/CSS3 - 现代化界面
- Ethers.js - 钱包连接与合约交互
- HTTP Server - 轻量级服务器
- Monad Testnet - 高性能 EVM 兼容链
- Chain ID: 10143
- Gas Token: MON
- 打开钱包设置
- 添加自定义网络
- 输入网络信息:
网络名称: Monad Testnet Chain ID: 10143 RPC URL: https://testnet-rpc.monad.xyz 货币符号: MON 区块浏览器: https://testnet.monadexplorer.com
// 支持的钱包
- MetaMask
- OKX Wallet
- 任何 EVM 兼容钱包// 调用合约函数
CardPack.buyPack() payable
// 价格: 0.01 MON
// 获得: 10 张随机 NFT 卡牌// 上架销售
Marketplace.listItem(tokenId, price)
// 直接购买
Marketplace.buyItem(tokenId) payable
// 竞拍出价
Marketplace.placeBid(tokenId) payable// 查询卡牌属性
function cardAttributes(uint256 tokenId)
view returns (CardAttributes memory)
// 创建新卡牌 (仅 Owner)
function createCard(address to)
onlyOwner returns (uint256)
// 查询总供应量
function totalSupply() view returns (uint256)// 购买卡包
function buyPack() payable
// 查询用户卡牌
function getUserCards(address user)
view returns (uint256[] memory)
// 查询卡包价格
function getPackPrice() pure returns (uint256)// 上架商品
function listItem(uint256 tokenId, uint256 price)
// 购买商品
function buyItem(uint256 tokenId) payable
// 出价竞拍
function placeBid(uint256 tokenId) payable
// 接受竞拍
function acceptBid(uint256 tokenId, address bidder)// 连接钱包 (支持 MetaMask/OKX)
await connectWallet()
// 检查网络
const network = await provider.getNetwork()
// 切换到 Monad 测试网
await switchToMonadTestnet()// 购买卡包
await contracts.cardPack.buyPack({ value: packPrice })
// 上架 NFT
await contracts.marketplace.listItem(tokenId, price)
// 查询用户资产
const userCards = await contracts.cardPack.getUserCards(address)# 运行所有测试
npx hardhat test
# 查看系统状态
npx hardhat run scripts/status.js --network monad-testnet
# 测试多用户访问
npx hardhat run scripts/multi-user-test.js --network monad-testnet
# 合约交互演示
npx hardhat run scripts/interact.js --network monad-testnet- ✅ 卡包购买 - 价格验证、随机性测试
- ✅ NFT 生成 - 属性分布、DNA 唯一性
- ✅ 市场交易 - 上架、购买、竞拍流程
- ✅ 事件追踪 - 所有关键操作的事件记录
- ✅ 多用户访问 - 钱包兼容性与权限测试
- ReentrancyGuard - 防重入攻击
- Ownable - 权限管理
- SafeMath - 溢出保护 (Solidity 0.8+)
- 输入验证 - 严格的参数检查
- 钱包验证 - 多重签名验证
- 网络检查 - 自动切换到正确网络
- 错误处理 - 全面的异常捕获
- 用户提示 - 清晰的操作反馈
- 合约审计 - 基于 OpenZeppelin 标准
- 测试覆盖 - 完整的单元测试
- 事件日志 - 所有操作可追踪
- 去中心化 - 无单点故障
系统支持多种语言,为全球用户提供友好的使用体验:
- 🇨🇳 中文 (默认)
- 🇺🇸 English
- 🇯🇵 日本語
- 🇰🇷 한국어
我们欢迎所有形式的贡献!
- Fork 项目仓库
- 创建 功能分支 (
git checkout -b feature/amazing-feature) - 提交 更改 (
git commit -m 'Add amazing feature') - 推送 分支 (
git push origin feature/amazing-feature) - 创建 Pull Request
- 使用 Issues 报告 Bug
- 提供详细的错误描述和复现步骤
- 附上相关的日志信息
- 在 Discussions 中提出新想法
- 描述功能的用途和价值
- 考虑实现的可行性
- ✅ 基础 NFT 卡牌系统
- ✅ 卡包购买与开启
- ✅ 去中心化交易市场
- ✅ 多钱包支持
- ✅ Monad 测试网部署
- 🔄 移动端适配
- 🔄 多语言国际化
- 🔄 高级筛选功能
- 🔄 交易数据分析
- 📋 卡牌战斗系统
- 📋 锦标赛模式
- 📋 社交功能
- 📋 DAO 治理
- 📋 主网部署
- 项目主页: Fantasy Top
- 区块浏览器: Monad Testnet Explorer
- Monad 官网: Monad.xyz
- 项目讨论: GitHub Discussions
- Bug 报告: GitHub Issues
- 技术支持: 开发者文档
本项目基于 MIT License 开源协议。
MIT License
Copyright (c) 2024 Fantasy Top Team
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
特别感谢以下项目和团队:
- Monad - 高性能区块链基础设施
- OpenZeppelin - 安全的智能合约框架
- Hardhat - 以太坊开发环境
- Ethers.js - 以太坊 JavaScript 库