0

Trying to use this Bitcoin Adapter

But having some issues specifically with the copyPath argument and the callback arguments.

For one, I would like to retrieve multiple parts of the JSON that is output, so I would think I need multiple copyPath arguments in my request but can't find any examples of that. I'm also not sure what arguments the callback fulfill function should have, I assume the type is string, but haven't found that defined anywhere.

Here's what I have so far, the node gets my request and processes it, but I'm getting nothing back in my callback (or maybe it's never being called).

    string public addr1;
    string public addr2;
    uint public value1;
    uint public value2;

    function makeRequest(string memory btcTX_ID) public {
        Chainlink.Request memory req = buildChainlinkRequest(jobId, address(this), this.fulfill.selector);
        req.add("rpc_command", "getRawTransaction");
        req.add("tx_id", btcTX_ID);
        req.add("copyPath", "result.data.tx.vout.0.scriptPubKey.addresses");
        req.add("copyPath", "result.data.tx.vout.0.value");
        req.add("copyPath", "result.data.tx.vout.1.scriptPubKey.addresses");
        req.add("copyPath", "result.data.tx.vout.1.value");
        sendChainlinkRequestTo(oracle, req, fee);
    }
    
    //callback function 
    function fulfill(bytes32 _requestId, string memory _addr1, uint _value1, string memory _addr2, uint _value2) public recordChainlinkFulfillment(_requestId) {
        addr1 = _addr1;
        value1 = _value1;
        addr2 = _addr2;
        value2 = _value2;
    }

Here's the doc page for using External Adapters in Solidity

2

It is currently only possible to return a single value of a bool, bytes32 or (u)int256. If the data is small enough, you can concatenate multiple values in an external adapter (e.g. join multiple integers with ","), and convert it to bytes32 on your own. In your smart contract, you would then decode it according to how you concatenated it in the EA.

Multiword responses is a feature that's in active development. You can follow the progress in the Pivotal tracker: https://www.pivotaltracker.com/epic/show/4157014

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.