1

我遵循了使用 kovan network 实现 Chainlink 的官方文档。我运行下面的代码

pragma 可靠性 0.6.6;导入“@chainlink/contracts/src/v0.6/Oracle.sol”;

【取自官方文档,https://remix.ethereum.org/#url=https://docs.chain.link/samples/NodeOperators/Oracle.sol

for node chainlink node job

    type = "directrequest"
schemaVersion = 1
name = "Get > Uint256"
# Optional External Job ID: Automatically generated if unspecified
# externalJobID = "b1d42cd5-4a3a-4200-b1f7-25a68e48aad8"
contractAddress = "YOUR_ORACLE_CONTRACT_ADDRESS"
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)"]

    decode_cbor  [type=cborparse data="$(decode_log.data)"]
    fetch        [type=http method=GET url="$(decode_cbor.get)"]
    parse        [type=jsonparse path="$(decode_cbor.path)" data="$(fetch)"]
    multiply     [type=multiply input="$(parse)" times=100]
    encode_data  [type=ethabiencode abi="(uint256 value)" data="{ \\"value\\": $(multiply) }"]
    encode_tx    [type=ethabiencode
                  abi="fulfillOracleRequest(bytes32 requestId, uint256 payment, address callbackAddress, bytes4 callbackFunctionId, uint256 expiration, bytes32 data)"
                  data="{\\"requestId\\": $(decode_log.requestId), \\"payment\\": $(decode_log.payment), \\"callbackAddress\\": $(decode_log.callbackAddr), \\"callbackFunctionId\\": $(decode_log.callbackFunctionId), \\"expiration\\": $(decode_log.cancelExpiration), \\"data\\": $(encode_data)}"
                 ]
    submit_tx    [type=ethtx to="YOUR_ORACLE_CONTRACT_ADDRESS" data="$(encode_tx)"]

    decode_log -> decode_cbor -> fetch -> parse -> multiply -> encode_data -> encode_tx -> enter code heresubmit_tx

"""

对于消费者,请使用以下代码 https://remix.ethereum.org/#url=https://docs.chain.link/samples/APIRequests/ATestnetConsumer.sol

错误代码片段: 链节节点作业中的错误

4

0 回答 0