Plugin,a Decentralized Oracle built on XDC Network
  • Migrating from Plugin Node V2 to V2.4 Without Changing the Node Address
    • 1 - Backup on Plugin Node V2.0
    • 2 - Installation and Configuration of Plugin Node V2.4
    • 3 - Importing PluginV2 Node Address into PluginV2.4
    • 4. Backup After Plugin V2.4 Upgrade
  • Plugin 2.0 - Node Operators
    • Introduction
    • Unstake PLI Tokens from Plugin 1.0 Node
    • Plugin 2.0 Set Up Requirements
    • Node Installation
      • Node Fulfillment
      • Job Setup
        • Steps to Setup Direct Request Job
      • Process of Approval
    • How to Update Your Plugin Node for the Latest XDC Gas Fee
  • PLUGIN 2.0 - Validators
    • Introduction
    • Set-up Requirements
    • Job Setup
      • Steps to Setup Direct Request Job
      • Flux Monitor Job
        • Idle Timer
        • Drum Beat
        • Poll Timer
        • POLL TIMER + IDLE TIMER (Recommended)
      • Process Of Approval
      • Rewards Information
    • OCR Set-up
    • How to Update Your Plugin Node for the Latest XDC Gas Fee
  • WALLET
    • XDCPay - Apothem
    • XDCPay - Mainnet
  • PLUGIN VRF SUBSCRIPTION
    • Introduction
    • Guidance on Utilizing Random Values
    • Creation and Deployment of VRF-Consumer Contract
    • Requesting Random Values
  • Multichain
    • PLISwap - How to instructions
  • Plugin Data Feeds platform
    • Introduction
    • End data consumers - Mainnet
    • End data consumers - Apothem
    • Benefits
  • Restaking Model
    • Introduction
      • Scenarios in Re-staking Model
      • Benefits To Node Members
      • Steps for Restaking
  • Tips and tricks
    • Known-Issues
    • Open-Issues
  • Plugin 1.0 Installations - Deprecated
    • How to install Plugin 1.0 Node
      • Modular Method Deployment (Recommended Approach)
      • Script Method (Legacy)
        • Script - Phase 1
        • Script - Phase 2
      • Docker Method
        • Docker - Phase 1
        • Docker - Phase 2
    • Core Adapters
    • Fund your Node
  • External Initiators - Deprecated
    • Introduction
    • Installation
    • Setup & Build
  • Oracle Plugin 1.0 - Deprecated
    • Deployment
    • Fulfillment Request
    • Job-Setup
    • Testing
  • Job-Tasks Plugin 1.0 Deprecated
    • Sleep
    • Get > Bytes32
    • HttpGet
    • CRON
    • Web
  • External Adapters Plugin 1.0 - Deprecated
    • Introduction
    • Implement External -Adapters
    • Define Bridge
    • Add Bridge to Job Spec
  • Deprecated
    • How to use
  • Use Cases
    • Plugin WFN Use Case
      • Plugin WFN Data Review
      • Plugin WFN Use Case - FAQ
      • Plugin WFN - Ambient Weather Unit Onboarding Instructions
      • Plugin WFN - Acurite Weather Unit Onboarding Instructions - LEGACY
      • Unlock WFN Node
    • Crypto Compare - Pricing Index
  • Node Operators
    • How to Register / Sign-up
    • How to enable 2FA
    • How to update profile
    • How to add XDC Wallet Address
    • How to Navigate Dashboards
    • How to submit Node Details
    • How to stake PLI token for Plugin Node
    • How to add Job to your node
    • View the node details
    • De-Activate / Re-activate my nodes
    • Withdraw staked PLI
    • Withdraw PLI from Plugin Node
    • Withdraw PLI from Oracle contract
    • How to add more stake in Node?
    • How to Migrate my Plugin Node to New Server?
    • How to Un-Stake the node.
    • How a Reputation is calculated?
    • Node Maintenance Instructions for node operators
  • FEATURES
    • PLI Yield Farming
      • Steps for Staking in Plugin Yield Farming (PLIYF)
      • PLIYF - FAQ
  • Support
    • FAQ
  • RESOURCES
    • Node Setup Video Tutorials
    • Community Supports
    • How to Submit your node details - Video Tutorial
  • CHANGELOG
    • v1.0.1
    • V1.0.2
    • V1.0.3
    • V1.0.4
    • V1.05
  • Terms and Conditions
Powered by GitBook
On this page
  • Weather Data UI
  • Pre-requisites
  • Steps For Using weather Data UI - Mainnet
  • Client Contract
  1. Use Cases
  2. Plugin WFN Use Case

Plugin WFN Data Review

PreviousPlugin WFN Use CaseNextPlugin WFN Use Case - FAQ

Last updated 1 year ago

Plugin offers weather data from Ambient, for the demo purpose the data lake units are being formed from various installation units at the Gulf location. This can be taken widely by setting up similar units across the globe, thus it forms a great data lake.

To execute or set up the weather data "Ambient" & how to contribute - Please wait for our directions.

Weather Data UI

The weather Data UI points to the link:

Pre-requisites

You need the following information to test the weather data onto your contract using the Weather Data UI.

  • Oracle Address

  • Job ID

  • API endpoint

  • Environment endpoint

Steps For Using weather Data UI - Mainnet

  • Write and deploy your client contract using the network details

  • Fund it with PLI

  • Call your request method with the following input params

    • Oracle Address

      • 0x1948745008E2704f8784e6654f76458BfF0Cdae5

    • Job ID

      • 9ce06be377d846ed9333ef835a342e64

    • API Endpoint

      • gettempbyids

    • Environment endpoint

      • Wind

      • Temperature

      • RelativeHumidity

      • HeatIndex

Client Contract

pragma solidity 0.4.24;

import "@goplugin/contracts/src/v0.4/vendor/Ownable.sol";
import "@goplugin/contracts/src/v0.4/PluginClient.sol";

contract ClientContract is PluginClient, Ownable {
      
   //Initialize Oracle Payment    
   uint256 constant private ORACLE_PAYMENT = 0.01 * 10**18;
   uint256 public Temperature;
   uint256 public Humidity;
   uint256 public HeatIndex;
   uint256 public WindSpeed;
 
   //Initialize event RequestWeatherFulfilled  
   event RequestWeatherFulfilled(
       bytes32 indexed requestId,
       uint256 indexed weather
   );
 
   //Initialize event requestCreated  
   event requestCreated(address indexed requester,bytes32 indexed jobId, bytes32 indexed requestId);
 
   //Constructor to pass Pli Token Address during deployment
   constructor(address _pli) public Ownable() {
       setPluginToken(_pli);
   }
 
   //_endCheck should be in these categories(WindDirection,Temperature,WindChill)
   //_endpoint should be getlatesttemp
   //_jobID should be tagged in Oracle
   //_Oracle should be fulfiled with your plugin node address
 
   function requestTemperature(address _oracle, string _jobId,string _endpoint,string _envCheck,string _countryId,string _stateId,string _cityId,string _latlng)
       public
       returns (bytes32 requestId)
   {
       Plugin.Request memory req = buildPluginRequest(stringToBytes32(_jobId), this, this.fulfillTemperature.selector);
       req.add("endpoint",_endpoint);
       req.add("envCheck",_envCheck);
       req.add("country",_countryId);
       req.add("state",_stateId);
       req.add("city",_cityId);
       req.add("latlng",_latlng);
       req.addInt("times", 100);
       requestId = sendPluginRequestTo(_oracle, req, ORACLE_PAYMENT);
       emit requestCreated(msg.sender, stringToBytes32(_jobId), requestId);
   }
 
 
   function requestHumidity(address _oracle, string _jobId,string _endpoint,string _envCheck,string _countryId,string _stateId,string _cityId,string _latlng)
       public
       returns (bytes32 requestId)
   {
       Plugin.Request memory req = buildPluginRequest(stringToBytes32(_jobId), this, this.fulfillHumidity.selector);
       req.add("endpoint",_endpoint);
       req.add("envCheck",_envCheck);
       req.add("country",_countryId);
       req.add("state",_stateId);
       req.add("city",_cityId);
       req.add("latlng",_latlng);
       req.addInt("times", 100);
       requestId = sendPluginRequestTo(_oracle, req, ORACLE_PAYMENT);
       emit requestCreated(msg.sender, stringToBytes32(_jobId), requestId);
   }
 
 
   function requestWindSpeed(address _oracle, string _jobId,string _endpoint,string _envCheck,string _countryId,string _stateId,string _cityId,string _latlng)
       public
       returns (bytes32 requestId)
   {
       Plugin.Request memory req = buildPluginRequest(stringToBytes32(_jobId), this, this.fulfillWindSpeed.selector);
       req.add("endpoint",_endpoint);
       req.add("envCheck",_envCheck);
       req.add("country",_countryId);
       req.add("state",_stateId);
       req.add("city",_cityId);
       req.add("latlng",_latlng);
       req.addInt("times", 100);
       requestId = sendPluginRequestTo(_oracle, req, ORACLE_PAYMENT);
       emit requestCreated(msg.sender, stringToBytes32(_jobId), requestId);
   }
 
   function requestHeatIndex(address _oracle, string _jobId,string _endpoint,string _envCheck,string _countryId,string _stateId,string _cityId,string _latlng)
       public
       returns (bytes32 requestId)
   {
       Plugin.Request memory req = buildPluginRequest(stringToBytes32(_jobId), this, this.fulfillHeatIndex.selector);
       req.add("endpoint",_endpoint);
       req.add("envCheck",_envCheck);
       req.add("country",_countryId);
       req.add("state",_stateId);
       req.add("city",_cityId);
       req.add("latlng",_latlng);
       req.addInt("times", 100);
       requestId = sendPluginRequestTo(_oracle, req, ORACLE_PAYMENT);
       emit requestCreated(msg.sender, stringToBytes32(_jobId), requestId);
   }
   //callBack function
   function fulfillTemperature(bytes32 _requestId, uint256 _weather)
       public
       recordPluginFulfillment(_requestId)
   {
       emit RequestWeatherFulfilled(_requestId, _weather);
       Temperature = _weather;
   }
 
   //callBack function
   function fulfillHeatIndex(bytes32 _requestId, uint256 _weather)
       public
       recordPluginFulfillment(_requestId)
   {
       emit RequestWeatherFulfilled(_requestId, _weather);
       HeatIndex = _weather;
   }
 
 
   //callBack function
   function fulfillWindSpeed(bytes32 _requestId, uint256 _weather)
       public
       recordPluginFulfillment(_requestId)
   {
       emit RequestWeatherFulfilled(_requestId, _weather);
       WindSpeed = _weather;
   }
 
 
   //callBack function
   function fulfillHumidity(bytes32 _requestId, uint256 _weather)
       public
       recordPluginFulfillment(_requestId)
   {
       emit RequestWeatherFulfilled(_requestId, _weather);
       Humidity = _weather;
   }
 
   function getPluginToken() public view returns (address) {
       return pluginTokenAddress();
   }
 
   //With draw pli can be invoked only by owner
   function withdrawPli() public onlyOwner {
       PliTokenInterface pli = PliTokenInterface(pluginTokenAddress());
       require(pli.transfer(msg.sender, pli.balanceOf(address(this))), "Unable to transfer");
   }
 
   //Cancel the existing request
   function cancelRequest(
       bytes32 _requestId,
       uint256 _payment,
       bytes4 _callbackFunctionId,
       uint256 _expiration
   )
       public
       onlyOwner
   {
       cancelPluginRequest(_requestId, _payment, _callbackFunctionId, _expiration);
   }
 
   //String to bytes to convert jobid to bytest32
   function stringToBytes32(string memory source) private pure returns (bytes32 result) {
       bytes memory tempEmptyStringTest = bytes(source);
       if (tempEmptyStringTest.length == 0) {
       return 0x0;
       }
       assembly {
       result := mload(add(source, 32))
       }
   }
   }

After deployment, you should fund your client contract with PLI(0.2 PLI)

After the contract is funded it has to be flattened using remix, for the convenience of the user the flattened form of the ClientContract is provided below.

WEATHER INFO

Select the filtering criteria like 'City', 'State', and 'Country' and click 'Show', you will be getting the latest weather info of the place you selected. After getting the result, move to the 'BLOCKCHAIN INFO' tab.

BLOCKCHAIN INFO

Deploy your contract tab details:

1) Select the 'Deploy your contract' tab and paste the flattened form of the contract and make sure you have selected the 'Mainnet' selection button and not 'Apothem', then press compile, after successful compilation you should get the ABI as the resultant.

2) Make sure you have XDC wallet installed and the account is pointing to 'mainnet', now click on the Deploy button. Now you should have got 'View Transaction' at the bottom, right-click on that and verify whether the transaction succeeded.

3) Copy and paste the 'ABI' contents from this page to a notepad.

Push Weather tab details:

1) Paste the copied ABI into the ABI field, client contract address (which is mentioned above as CC) into the 'Contract Address' field, oracle address, and job id to the respective fields.

2) Select an 'Environmental check' and click on Submit.

3) Once the transaction is done successfully you will get the 'View Transaction' button, click on it and verify the transaction status as 'success'. On the same page you can find the 'To:' field, copy the address in this field, and fund the address with 0.1 PLI

Show Weather tab details:

1) Paste the address which you copied and fund the same in 'Weather tab details' into 'Request Contract' field. Make sure you replaced the 'xdc' to '0x' at the start of the address.

2) Paste the ABI content into the 'ABI' field, select the 'Environmental check' field which you pushed and click submit, you will be receiving the weather details whatever you just pushed onto the plugin blockchain.

10 DAYS RECORD

In this tab the user can witness the 10 days of data for the selected location. Currently, the weather details include Temperature, Wind, Humidity and, HeatIndex.

Deploy the above ClientContract using . Once the contract is deployed, it has to be funded(0.2 PLI). For the sake of convenience, we can call the address of this contract CC for now.

Now you can go to the weather Data UI -

https://wfn.goplugin.co/
http://remix.ethereum.org/
link
35KB
ClientContractFlattened.sol