Chainlink Job报错decode_log.data not found问题排查求助
问题成因
你遇到的报错由以下3个核心问题导致:
- 日志解码ABI的
indexed标记和链上实际Operator合约的OracleRequest事件定义不匹配:标准Chainlink Operator合约的OracleRequest事件有3个带indexed修饰的参数(specId、requester、requestId),你配置的ABI仅标注了specId为indexed,导致日志解析时参数错位,解码出的字段结构错误,自然无法提取decode_log.data。 - 未显式定义任务执行顺序:Chainlink节点的observationSource需要明确指定任务的执行依赖关系,你只声明了三个任务但未指定执行流,节点可能乱序执行任务,decode_cbor运行时decode_log还未完成输出,自然找不到对应键。
- Bridge任务的requestData存在JSON格式问题:你传入的userId、contractId等都是字符串类型,但是配置中没有给变量插值结果加双引号,会导致后续JSON解析失败。
解决方案
按以下步骤修正Job配置即可:
- 修正OracleRequest事件的ABI标记,补全3个indexed参数
- 在observationSource末尾添加任务执行流,明确执行顺序
- 给bridge任务requestData中的字符串参数插值结果加上双引号
修正后的完整Job配置参考:
type = "directrequest" schemaVersion = 1 name = "TgetherisPaid" contractAddress = "0x7CbeF9F1C57b13d412D7651D8a1cFb898600952C" maxTaskDuration = "1s" observationSource = """ decode_log [type=ethabidecodelog abi="OracleRequest(bytes32 indexed specId, address indexed requester, bytes32 indexed 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.data)"] my_bridge_task [type="bridge" name="tgether_ispaid_el_ea" requestData="{\\"data\\":{\\"userid\\": \"$(decode_cbor.userId)\", \\"contractId\\": \"$(decode_cbor.contractId)\", \\"amountPaid\\": \"$(decode_cbor.amountPaid)\"}}" ] // 显式指定任务执行顺序 decode_log -> decode_cbor -> my_bridge_task """
配置生效后重新发起请求即可正常完成日志解码、CBOR参数解析,顺利调用外部适配器。
内容的提问来源于stack exchange,提问作者Joe
相关产品推荐
相关产品推荐

