You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何从预言机获取Polymarket umaResolutionStatus为proposed时的提议值?

获取Polymarket UMA预言机proposed状态的提议值

直接从UMA预言机获取提议值的核心方式是调用UMA预言机合约的内置方法,而非依赖第三方接口,具体步骤如下:

  • 第一步:定位目标合约
    找到Polymarket对应市场关联的UMA预言机合约(通常是OptimisticOracleV2),可以通过区块链浏览器查看Polymarket市场合约的oracle或类似字段获取地址。同时从Polymarket的市场合约中提取oracleRequestId——这个ID是关联预言机请求的唯一标识。

  • 第二步:调用预言机合约的getRequest方法
    用Web3库(比如ethers.js)连接区块链后,调用预言机合约的getRequest(uint256 requestId)方法,传入上面拿到的oracleRequestId。返回的结构体里包含以下关键字段:

    • proposedPrice: 这就是状态为proposed时的提议值
    • status: 用于确认当前请求状态,UMA合约中proposed对应的枚举值通常为2(可查看合约源码的RequestStatus枚举确认)
  • 代码示例(ethers.js)

    import { ethers } from "ethers";
    
    // 替换为实际的预言机合约地址和请求ID
    const ORACLE_ADDRESS = "0x...";
    const REQUEST_ID = "0x...";
    
    // 连接到区块链节点
    const provider = new ethers.providers.JsonRpcProvider("YOUR_RPC_URL");
    
    // UMA OptimisticOracleV2合约的ABI片段(仅包含getRequest方法)
    const oracleAbi = [
      "function getRequest(uint256 requestId) external view returns (tuple(uint256 proposedPrice, uint256 status, ...))"
    ];
    
    const oracleContract = new ethers.Contract(ORACLE_ADDRESS, oracleAbi, provider);
    
    // 获取请求详情
    const requestDetails = await oracleContract.getRequest(REQUEST_ID);
    console.log("提议值:", requestDetails.proposedPrice.toString());
    console.log("当前状态:", requestDetails.status.toString()); // 若为2则是proposed状态
    
  • 注意事项

    • 如果无法从Polymarket市场合约直接拿到oracleRequestId,可以调用市场合约的getResolutionInfo或类似方法,通常会返回包含请求ID的解析详情。
    • 确保连接的区块链节点对应Polymarket部署的链(比如主网、Arbitrum等)。

内容的提问来源于stack exchange,提问作者Youshikyou

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.11 22:32:34