FlightAware Chainlink (Testnet)

FlightAware Chainlink (Testnet) Tutorial

This Chainlink has a dedicated connection to FlightAware.

Steps for using this oracle

  1. Write and deploy your Chainlink contract using the network details provided.
  2. Fund the contract with LINK.
  3. Call your request method.

Use the following addresses and Job IDs for the Kovan network to create requests:

  • LINK Token address: 0xa36085f69e2889c224210f603d836748e7dc0088
  • Oracle address: 0x2f90A6D021db21e1B2A077c5a37B3C7E75D15b7e
  • JobID: a644d4e30977459d9a596bef89c09e71
  • Sleep JobID: f0003b2c52024e7fa931d6ee9a947c87

To inherit Chainlink behavior, you must import ChainlinkClient.sol.

Basic Contract Structure (Solidity 0.6.0):

pragma solidity ^0.6.0; 

import "@chainlink/contracts/src/v0.6/ChainlinkClient.sol"; 

contract FlightAwareChainlink is ChainlinkClient {
  uint256 oraclePayment;

  constructor(uint256 _oraclePayment) public {     
      setPublicChainlinkToken();     
      oraclePayment = _oraclePayment;   
  }   
  // Additional functions here...
}

Tasks

The oracle performs the following tasks:

  • FlightAware
  • Copy
  • Ethuint256
  • EthTx

Request Parameters

  • endpoint: The endpoint to query (optional, defaults to FlightInfoEx).
  • flight: The flight identification or number (required).
  • departure: The unix timestamp of the departure (required).
  • until: Required for the Sleep job.

Solidity Code Examples for Parameters:

req.add("endpoint", "FlightInfoEx");
req.add("flight", "NAX105");
req.addUint("departure", 1594378824);
req.addUint("until", now + 1 hours);

The createRequest Method:

function createRequest (   
    address _oracle,   
    bytes32 _jobId,   
    string memory _flight,   
    uint256 _departure
) public onlyOwner {   
    Chainlink.Request memory req = buildChainlinkRequest(_jobId, address(this), this.fulfill.selector);   
    req.add("flight", _flight);   
    req.addUint("departure", _departure);   
    sendChainlinkRequestTo(_oracle, req, oraclePayment); 
}

The fulfill Method:

uint256 public result; 

function fulfill(bytes32 _requestId, uint256 _result)   
    public   
    recordChainlinkFulfillment(_requestId) 
{   
    result = _result; 
}

On this page