Ethereum

Ethereum 链上归因——将链上交易与 AI 行为归因打通,实现 DeFi / NFT / DApp 场景的可验证归因

Ethereum 归因的特殊挑战

链规格与 Fly 适配

规格 Ethereum Fly 适配方式
共识机制 Proof of Stake (PoS) 区块确认后触发归因验证
区块时间 ~12秒 实时监听,低延迟归因
Gas 机制 EIP-1559 + 小费 Gas 消耗计入行为成本
代币标准 ERC-20/721/1155 分别追踪转账、铸造、交易
智能合约 Solidity Vyper 合约交互自动生成 Behavior ID

完整归因链路

1
AI 推荐
Agent → 用户
2
钱包连接
MetaMask → wlt_xxx
3
合约交互
swap/mint/claim
4
交易确认
tx_hash
5
归因绑定
ACT_xxx ↔ tx_hash

支持场景

DEX 交易归因
AI Agent 推荐了某代币 ↓ 用户在 Uniswap V3 上 swap ↓ Fly 捕获: swap 事件 + tx_hash + 用户钱包 ↓ 归因: "这笔 swap 来自 AI 推荐,贡献了 $X 交易量"
NFT 铸造归因
AI Agent 推荐了 NFT 项目 ↓ 用户在铸造页面 mint ↓ Fly 捕获: mint 事件 + tokenId + tx_hash ↓ 归因: "这个 NFT 来自 AI 渠道,可以分配白名单或佣金"
借贷协议归因
AI Agent 推荐了高收益借贷池 ↓ 用户在 Aave 存入资产 ↓ Fly 捕获: deposit 事件 + 金额 + tx_hash ↓ 归因: "这笔存款来自 AI 推荐,TVL 贡献可追踪"
空投领取归因
AI Agent 通知用户有空投资格 ↓ 用户 claim 代币 ↓ Fly 捕获: claim 事件 + 数量 + tx_hash ↓ 归因: "这次空投的 X% 来自 AI 渠道用户"

技术实现

// 监听 Uniswap V3 Swap 事件
contract UniswapV3Pool {
  event Swap(
    address indexed sender,
    address indexed recipient,
    int256 amount0,
    int256 amount1,
    uint160 sqrtPriceX96
  );
}

// Fly 监听 Swap 事件,匹配已注册钱包
if (walletRegistry.isRegistered(recipient)) {
  // 创建归因记录
  createAttribution({
    tx_hash,
    wallet_id: getWalletId(recipient),
    action_type: "DEX_SWAP",
    amount: Math.abs(amount0)
  });
}

API 接口

POST /v1/web3/ethereum/attributions
{"tx_hash": "0xtx_abc", "event_type": "swap", "contract": "0xUniswapV3"}
创建 Ethereum 链上交易归因记录
GET /v1/web3/ethereum/transactions
?wallet_id=wlt_xxx&event_type=swap&limit=20
查询钱包的 Ethereum 交易归因列表
GET /v1/web3/ethereum/stats
?period=7d
查询 Ethereum 链归因统计(交易量、用户数、Gas 消耗)
数据模型就绪 · 链上接入规划中