收尾:后续方向
你已经搭建了一个 AI 驱动的预测市场。下面从头到尾梳理完整流程。
完整端到端流程
从创建市场到领取奖金的完整路径如下:
┌─────────────────────────────────────────────────────────────────┐
│ COMPLETE FLOW │
├─────────────────────────────────────────────────────────────────┤
│ │
│ 0. DEPLOY CONTRACT (Foundry) │
│ └─► forge create → PredictionMarket deployed on Sepolia │
│ │
│ 1. CREATE MARKET (HTTP Trigger) │
│ └─► HTTP Request → CRE Workflow → EVM Write → Market Live │
│ │
│ 2. PLACE PREDICTIONS (Direct Contract Calls) │
│ └─► Users call predict() with ETH stakes │
│ │
│ 3. REQUEST SETTLEMENT (Direct Contract Call) │
│ └─► Anyone calls requestSettlement() → Emits Event │
│ │
│ 4. SETTLE MARKET (Log Trigger) │
│ └─► Event → CRE Workflow → AI Query → EVM Write → Settled │
│ │
│ 5. CLAIM WINNINGS (Direct Contract Call) │
│ └─► Winners call claim() → Receive ETH payout │
│ │
└─────────────────────────────────────────────────────────────────┘
步骤 0:部署合约
source .env
cd prediction-market/contracts
forge create src/PredictionMarket.sol:PredictionMarket \
--rpc-url "https://ethereum-sepolia-rpc.publicnode.com" \
--private-key $CRE_ETH_PRIVATE_KEY \
--broadcast \
--constructor-args 0x15fc6ae953e024d975e77382eeec56a9101f9f88
保存部署地址并更新 config.staging.json:
export MARKET_ADDRESS=0xYOUR_DEPLOYED_ADDRESS
步骤 1:创建市场
cd .. # make sure you are in the prediction-market directory
cre workflow simulate my-workflow --broadcast
选择 HTTP trigger(选项 1),然后输入:
{"question": "Will Argentina win the 2022 World Cup?"}
步骤 2:下注预测
# Predict YES on market #0 with 0.01 ETH
cast send $MARKET_ADDRESS \
"predict(uint256,uint8)" 0 0 \
--value 0.01ether \
--rpc-url "https://ethereum-sepolia-rpc.publicnode.com" \
--private-key $CRE_ETH_PRIVATE_KEY
步骤 3:请求结算
cast send $MARKET_ADDRESS \
"requestSettlement(uint256)" 0 \
--rpc-url "https://ethereum-sepolia-rpc.publicnode.com" \
--private-key $CRE_ETH_PRIVATE_KEY
保存交易哈希!
步骤 4:通过 CRE 结算
cre workflow simulate my-workflow --broadcast
选择 Log trigger(选项 2),输入 tx hash 与 event index 0。
步骤 5:领取奖金
cast send $MARKET_ADDRESS \
"claim(uint256)" 0 \
--rpc-url "https://ethereum-sepolia-rpc.publicnode.com" \
--private-key $CRE_ETH_PRIVATE_KEY
接下来做什么?
可探索的方向:
- Stablecoin 发行
- 代币化资产服务与全生命周期管理
- 自定义 Proof of Reserve 数据喂价
- AI 驱动的预测市场结算
- 使用链下数据的事件驱动型市场决议
- 自动化风险监控
- 实时储备健康检查
- 协议保护触发器
- 通过 x402 支付消费 CRE workflow 的 AI Agent
- AI Agent 的区块链抽象层
- AI 辅助的 CRE workflow 生成
- 跨链 workflow 编排
- 面向 Web3 应用的去中心化后端 workflow
- CRE workflow 搭建工具与可视化
- 还有更多……
📚 探索更多用例
- Stablecoin Issuance - 自动化储备验证
- Tokenized Asset Servicing - 现实世界资产管理
- AI-Powered Prediction Markets - 你刚刚完成了这个!
- AI Agents with x402 Payments - 自主 agent
- Custom Proof of Reserve - 透明度基础设施
🔗 实用 CRE 链接
- Consensus Computing
- Finality and Confidence Levels
- Secrets Management
- Deploying Workflows
- Monitoring & Debugging Workflows
🚀 部署到生产环境
准备上线?申请 Early Access:
💬 加入社区
- Discord - 获取帮助并分享你的作品
- Developer Docs - 深入 CRE
- GitHub - 浏览示例