【发布时间】:2021-11-18 09:39:07
【问题描述】:
我在我的 Chainlink 节点上收到了还原的交易,我正在寻找一些关于如何调试它的提示。节点接收到 Oracle 请求,作业成功运行。我的完成功能是最小的:
function checkConditions(address _oracle, string memory _jobId) external {
setPublicChainlinkToken();
Chainlink.Request memory request = buildChainlinkRequest(
stringToBytes32(_jobId),
address(this),
this.fulfill.selector
);
request.add("ytChannelId", "UCfpnY5NnBl-8L7SvICuYkYQ");
sendChainlinkRequestTo(
_oracle,
request,
1 * LINK_DIVISIBILITY
);
}
event OnFulfill(uint256 _ytViews, uint256 _ytSubs);
function fulfill(
bytes32 _requestId,
uint256 _ytViews,
uint256 _ytSubs
) public recordChainlinkFulfillment(_requestId) {
emit OnFulfill(_ytViews, _ytSubs);
}
我从 github blob 改编了作业规范,因为它是一个带有桥的多变量作业,这正是我的用例。我的 .toml 文件:
type = "directrequest"
schemaVersion = 1
name = "mysocialcontract-ea-job"
contractAddress = "0x2Db11F9E1d0a1cDc4e3F4C75B4c14f4a4a1a3518"
maxTaskDuration = "0s"
observationSource = """
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)"]
decodecbor [type="cborparse" data="$(decode_log.data)"]
fetch [type="bridge" name="mysocialcontract" requestData="{\\"id\\": \\"0\\", \\"data\\": {\\"ytChannelId\\": $(decodecbor.ytChannelId)}}"]
decode_log -> decodecbor -> fetch
ytSubs [type=jsonparse path="result,ytSubs"]
ytViews [type=jsonparse path="result,ytViews"]
fetch -> ytSubs
fetch -> ytViews
ytSubs -> encode_mwr
ytViews -> encode_mwr
encode_mwr [type=ethabiencode abi="(bytes32 _requestId, uint256 _ytViews, uint256 _ytSubs)"
data="{\\"_requestId\\": $(decode_log.requestId),\\"_ytViews\\": $(ytViews),\\"_ytSubs\\": $(ytSubs)}"]
encode_tx [type=ethabiencode
abi="fulfillOracleRequest2(bytes32 requestId, uint256 payment, address callbackAddress, bytes4 callbackFunctionId, uint256 expiration, bytes calldata data)"
data="{\\"requestId\\": $(decode_log.requestId), \\"payment\\": $(decode_log.payment), \\"callbackAddress\\": $(decode_log.callbackAddr), \\"callbackFunctionId\\": $(decode_log.callbackFunctionId), \\"expiration\\": $(decode_log.cancelExpiration), \\"data\\": $(encode_mwr)}"]
submit [type=ethtx to="0x2Db11F9E1d0a1cDc4e3F4C75B4c14f4a4a1a3518" data="$(encode_tx)" gasLimit="5000000"]
encode_mwr -> encode_tx -> submit
"""
来自我最后一次尝试的交易:https://kovan.etherscan.io/tx/0x2b58d0b9c6a6718817acbfb4cfb1bdcc893b28cedf111a8b5293473842a9a9c3
这是我的设置:
- 在 AWS 上部署的 Chainlink 节点。
- 我自己的网桥 + 外部适配器。
- 使用硬编码值在 Remix IDE 上测试 Oracle 的小功能。
【问题讨论】: