一个简单的单页面应用,允许任何人免费领取 SBT 和 PNT tokens 用于测试 SuperPaymaster。
- 🎁 无需认证: 不需要连接钱包
- 💧 免费领取:
- 每个地址可领取 1 个 SBT
- 每次可领取 100 PNT
- 🔒 限流保护: 每个地址每小时最多 2 次请求
- ⛽ Gas 由我们支付: 使用 backend 私钥支付所有 gas 费用
- SBT:
0xBfde68c232F2248114429DDD9a7c3Adbff74bD7f
(MySBT) - PNT:
0xD14E87d8D8B69016Fcc08728c33799bD3F66F180
(PNTv2 - GasTokenV2) - Network: Sepolia Testnet
cd faucet-app
npm install
复制 .env.example
到 .env
并填入:
SEPOLIA_RPC_URL=https://eth-sepolia.g.alchemy.com/v2/YOUR_API_KEY
SEPOLIA_PRIVATE_KEY=0x... # Owner 私钥(必须有 ETH 用于 gas)
SBT_CONTRACT_ADDRESS=0xBfde68c232F2248114429DDD9a7c3Adbff74bD7f
PNT_TOKEN_ADDRESS=0xD14E87d8D8B69016Fcc08728c33799bD3F66F180
npm run dev
# 测试 mint SBT
curl -X POST http://localhost:3000/api/mint \
-H "Content-Type: application/json" \
-d '{"address": "0xYourAddress", "type": "sbt"}'
# 测试 mint PNT
curl -X POST http://localhost:3000/api/mint \
-H "Content-Type: application/json" \
-d '{"address": "0xYourAddress", "type": "pnt"}'
npm i -g vercel
vercel login
在 Vercel 项目设置中添加:
SEPOLIA_RPC_URL
SEPOLIA_PRIVATE_KEY
SBT_CONTRACT_ADDRESS
PNT_TOKEN_ADDRESS
或使用 Vercel CLI:
vercel env add SEPOLIA_RPC_URL
vercel env add SEPOLIA_PRIVATE_KEY
# 部署到生产环境
npm run deploy
# 或使用 vercel CLI
vercel --prod
领取 tokens
Request Body:
{
"address": "0x...",
"type": "sbt" | "pnt"
}
Success Response (200):
{
"success": true,
"txHash": "0x...",
"blockNumber": 12345,
"amount": "1 SBT" | "100 PNT",
"recipient": "0x...",
"type": "sbt" | "pnt",
"network": "Sepolia"
}
Error Response:
{
"success": false,
"error": "Error message"
}
400
: 参数错误或地址已领取429
: 超过请求限制500
: 服务器错误
- 每个地址只能领取 1 个 SBT
- 每个地址每小时最多 2 次请求(SBT 和 PNT 分别计数)
- Owner 私钥必须有足够的 ETH 用于支付 gas
- 不要在公共代码中暴露私钥
- 使用 Vercel 环境变量管理敏感信息
- Owner 账户应该只用于 faucet,不要存放大量资金
- 定期检查 owner 账户的 ETH 余额
faucet-app/
├── public/
│ └── index.html # 单页面前端
├── api/
│ └── mint.js # Vercel Serverless Function
├── package.json
├── vercel.json # Vercel 配置
└── .env # 环境变量(不提交到 git)
- 前端: 纯 HTML/CSS/JavaScript
- 后端: Vercel Serverless Functions
- 智能合约: Solidity + ethers.js
- 部署: Vercel
MIT