Biomass and Tree Validation Integration

The below Examples show how to directly Query the API via Oracle Node

Setting Up The Request

The Request requires the above versions of solidity and Chainlink libs. The first example shows a simply biomass request to the node. Please use the above endpoints for adjusting to your network.

The below code shows the smart contract function that will call the oracle node.

function requestTreePresenceToMintExample() public onlyOwner {
        address _oracle = 0x67CB6fc6C1Fd1C2D01698f074F50E2DE5F4E2970;
        string memory _jobId = "fc009ee445d848c7b8e1632e840e635c";
        int256 _month = 6;
        // will return 1 (uint256) in variable mintFlag when called
        Chainlink.Request memory req = buildChainlinkRequest(
            stringToBytes32(_jobId),
            address(this),
            this.fulfillTreePresence.selector
        );
        req.add('siteId', '0001');
        req.addInt('year', 2022);
        req.addInt('month', _month);
        sendChainlinkRequestTo(_oracle, req, ORACLE_PAYMENT);
    }

The key elemenets here are wapping the required fields into the request body, which when is sent via the sendChainlinkRequestTo() method at the end of the function. The next part is unwrapping the response.

Which unwraps into the public variable.

The full example is below:

The above also highlights other ways to query the node.

Multi Reponse and More details

Below we will highlight how to get multiple response back from the node with a full example.

Good to know: Multi Reponse requires a slightly different address, so please note the details. The example shows details for the Mumbai test network.

Last updated