【问题标题】:Chainlink job not executing but node receiving link feeChainlink 作业未执行但节点接收链接费用
【发布时间】:2021-12-28 14:32:36
【问题描述】:

我有一个在 evm 测试网中运行的 chainlink 节点。我已经部署了链接令牌和预言机合约,用以太币为我的节点账户提供资金,创建了一个作业和一个向该作业发送请求的智能合约。我在我的 Chainlink.Request 中使用作业定义中的 externalJobID。我的 oracle 帐户正在从合同执行和请求中收取链接费,但我的工作没有执行。我在我的 chainlink 节点日志中看不到任何内容。

这是我的合约代码

contract Metadata is ChainlinkClient{
    address private oracle;
    bytes32 private jobId;
    uint256 private fee;

    //event variables
    struct EMetaData{
        address dataToken;
        bytes   flags;
        bytes   data;
        address sender;
    }

    mapping(bytes32 => EMetaData) public metadatas;

    constructor() public {
        setChainlinkOracle(0x6a61789194260F0BE95a18d0116d883A4b5284ed);
        setChainlinkToken(0xa38F087411e0908ad87b40Ab4D7Ca9247DE0052e);
        jobId  = "3a3e489f1fd145b385a18728c6947508";
        fee    = 0.1 * 10 ** 18; // (0.1 LINK)
    }


    event MetadataCreated(
        address indexed dataToken,
        address indexed createdBy,
        bytes flags,
        bytes data
    );

    function testCreate(
        address _dataToken,
        bytes memory _flags,
        bytes memory _data
     ) public returns (bytes32 requestId){

        Chainlink.Request memory request = buildChainlinkRequest(jobId, address(this), this.fulfill.selector);

        metadatas[request.id].dataToken = _dataToken;
        metadatas[request.id].flags = _flags;
        metadatas[request.id].data = _data;
        metadatas[request.id].sender = msg.sender;

        return sendChainlinkRequest(request, fee);
    }

    function fulfill(bytes32 _requestId, bool result) public{
        require(result == true, "Validation Failed");
         emit MetadataCreated(
            metadatas[_requestId].dataToken,
            metadatas[_requestId].sender,
            metadatas[_requestId].flags,
            metadatas[_requestId].data
        );
    }

  }
}

这是我的工作规范

type = "directrequest"
schemaVersion = 1
name = "Shacl validation"
contractAddress = "0x95D57363B491CF743970c640fe419541386ac8BF"
maxTaskDuration = "20s"
observationSource = """
    decode_log  [type="ethabidecodelog"
                data="$(jobRun.logData)"
                topics="$(jobRun.logTopics)"
                abi="SomeContractEvent(bytes32 requestID, bytes cborPayload)"]

    decode_cbor [type="cborparse"
                data="$(decode_log.cborPayload)"]

    ds          [type="http" method=POST url="http://localhost:3000/api/v1/aquarius/assets/ddo/validate"]
    ds_parse    [type="jsonparse" path=""]
    encode_response [type="ethabiencode"
                     abi="(bool data)"
                     data="{\\"data\\": $(ds_parse) }"]
    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_response)}"
               ]
    submit_tx [type="ethtx" to="0x95D57363B491CF743970c640fe419541386ac8BF" data="$(encode_tx)"]

    decode_log -> decode_cbor -> ds -> ds_parse -> encode_response -> encode_tx -> submit_tx
"""
externalJobID = "3a3e489f-1fd1-45b3-85a1-8728c6947508"

----------- 编辑 0x6a61789194260F0BE95a18d0116d883A4b5284ed是chainlink节点账户

0x95D57363B491CF743970c640fe419541386ac8BF 是预言机合约地址

【问题讨论】:

    标签: chainlink


    【解决方案1】:

    只是从 Discord 中提取答案,以便其他人更容易找到它(因为术语节点地址和预言机地址经常被混淆):

    0x6a61789194260F0BE95a18d0116d883A4b5284ed 是您的 Chainlink 节点的地址(您可以在 GUI 的键选项卡中看到),需要使用 ETH 为该节点提供资金才能在链上发送交易。 Chainlink节点监听job spec中使用的oracle智能合约发出的事件日志,oracle地址不是你部署它的账号,而是新部署的oracle智能合约的地址,请务必按照以下步骤操作: https://docs.chain.link/docs/fulfilling-requests/#deploy-your-own-oracle-contract

    您可以在 Remix 和底层网络的区块浏览器中找到预言机合约地址,这是您需要在消费者合约中使用才能成功请求,然后可以从预言机合约中提取 LINK 奖励。

    【讨论】:

      【解决方案2】:

      在对 Chainlink discord 进行了一些讨论后,我得到了一些帮助

      问题是我将我的chainlink节点帐户传递给Chainlink.Request对象,正确的是传递oracle合约地址。

      【讨论】:

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