【问题标题】:Does anyone have an example Chainlink Large response Toml job specs for Chainlink node operators?有没有人有 Chainlink 节点操作员的 Chainlink 大响应 Toml 作业规范示例?
【发布时间】:2022-01-21 15:52:37
【问题描述】:

有没有人有针对 Chainlink 节点操作员的 Chainlink Large response Toml 作业规范的示例?

我能找到的唯一例子是 json:

{
  "name": "large-word",
  "initiators": [
    {
      "id": 9,
      "jobSpecId": "7a97ff84-93ec-406d-9062-1b2531f9251a",
      "type": "runlog",
      "params": {
        "address": "0xc57b33452b4f7bb189bb5afae9cc4aba1f7a4fd8"
      }
    }
  ],
  "tasks": [
    {
      "jobSpecId": "7a97ff8493ec406d90621b2531f9251a",
      "type": "httpget"
    },
    {
      "jobSpecId": "7a97ff8493ec406d90621b2531f9251a",
      "type": "jsonparse"
    },
    {
      "jobSpecId": "7a97ff8493ec406d90621b2531f9251a",
      "type": "resultcollect"
    },
    {
      "jobSpecId": "7a97ff8493ec406d90621b2531f9251a",
      "type": "ethtx",
      "confirmations": 1,
      "params": {
        "abiEncoding": [
          "bytes32",
          "bytes"
        ]
      }
    }
  ]
}

我们只是改变 Abi 编码吗?

任何帮助将不胜感激。谢谢

【问题讨论】:

    标签: chainlink


    【解决方案1】:

    您可以通过一个简单的 V2 直接请求作业来实现这一点,您只需要确保您的 ABI 和参数编码正确,并且符合合同的预期,V2 不需要 resultCollect。除此之外,您需要使用 v0.7 及更高版本的Operator.sol 作为您的预言机合约,而不是旧的Oracle.sol,因为这是具有为数据获取字节参数的fulfillOracleRequest2 函数的合约,如与 bytes32 参数相反(它限制了响应的大小)

    decode_log   [type="ethabidecodelog"
                  abi="OracleRequest(bytes32 indexed specId, address requester, bytes32 requestId, uint256 payment, address callbackAddr, bytes4 callbackFunctionId, uint256 cancelExpiration, uint256 dataVersion, bytes data)"
                  data="$(jobRun.logData)"
                  topics="$(jobRun.logTopics)"]
    
    decode_cbor [type="cborparse"
                 data="$(decode_log.cborPayload)"]
    
    // Then, we use the decoded request parameters to make an HTTP fetch
    fetch [type="http" method=GET url="$(decode_cbor.fetchURL)"]
    parse [type="jsonparse" path="$(decode_cbor.jsonPath)" data="$(fetch)"]
    
    // Finally, we send a response on-chain.
    // Note that single-word responses automatically populate
    // the requestId.
    encode_response [type="ethabiencode"
                     abi="(bytes data)"
                     data="{\\"data\\": $(parse) }"]
    
    encode_tx       [type="ethabiencode"
                     abi="fulfillOracleRequest2(bytes32 requestId, uint256 payment, address callbackAddress, bytes4 callbackFunctionId, uint256 expiration, bytes data)"
                     data="{\\"requestId\\": $(decode_log.requestId), \\"payment\\": $(decode_log.payment), \\"callbackAddress\\": $(decode_log.callbackAddr), \\"callbackFunctionId\\": $(decode_log.callbackFunctionId), \\"expiration\\": $(decode_log.cancelExpiration), \\"data\\": $(encode_response)}"
                     ]
    
    submit_tx  [type="ethtx" to="0xc57b33452b4f7bb189bb5afae9cc4aba1f7a4fd8" data="$(encode_tx)"]
    
    decode_log -> decode_cbor -> fetch -> parse -> encode_response -> encode_tx -> submit_tx
    

    【讨论】:

      猜你喜欢
      • 2021-11-07
      • 1970-01-01
      • 2022-01-18
      • 2021-11-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多