# Existing Job Request
Source: https://docs.chain.link/any-api/get-request/examples/existing-job-request

> For the complete documentation index, see [llms.txt](/llms.txt).

<AnyApiCallout callout="usefunctions" />

Using an *existing* Oracle Job makes your smart contract code more succinct. This page explains how to retrieve the gas price from an existing Chainlink job that calls [etherscan gas tracker API](https://docs.etherscan.io/api-endpoints/gas-tracker#get-gas-oracle).

## Example

In [Single Word Response Example](/any-api/get-request/examples/single-word-response), the example contract code declared which URL to use, where to find the data in the response, and how to convert it so that it can be represented onchain.

This example uses an existing job that is pre-configured to make requests to get [the gas price](https://docs.etherscan.io/api-endpoints/gas-tracker#get-gas-oracle). Using specialized jobs makes your contracts succinct and more simple.

[Etherscan gas oracle](https://docs.etherscan.io/api-endpoints/gas-tracker#get-gas-oracle) returns the current Safe, Proposed and Fast gas prices. To check the response, you can directly paste the following URL in your browser `https://api.etherscan.io/api?module=gastracker&action=gasoracle&apikey=YourApiKeyToken` or run this command in your terminal:

```bash
curl -X 'GET' \
  'https://api.etherscan.io/api?module=gastracker&action=gasoracle&apikey=YourApiKeyToken' \
  -H 'accept: application/json'
```

The response should be similar to the following:

```json
{
  "status": "1",
  "result": {
    "LastBlock": "14653286",
    "SafeGasPrice": "33",
    "ProposeGasPrice": "33",
    "FastGasPrice": "35",
    "suggestBaseFee": "32.570418457",
    "gasUsedRatio": "0.366502543599508,0.15439818258491,0.9729006,0.4925609,0.999657066666667"
  }
}
```

For this example, we created a job that leverages the [EtherScan External Adapter](https://github.com/smartcontractkit/external-adapters-js/tree/develop/packages/sources/etherscan) to fetch the *SafeGasPrice* , *ProposeGasPrice* and *FastGasPrice*. You can learn more about External Adapters [here](/chainlink-nodes/external-adapters/external-adapters).
To consume an API, your contract must import [ChainlinkClient.sol](https://github.com/smartcontractkit/chainlink/blob/contracts-v1.3.0/contracts/src/v0.8/ChainlinkClient.sol). This contract exposes a struct named `Chainlink.Request`, which your contract can use to build the API request. The request must include the following parameters:

- Link token address
- Oracle address
- Job id
- Request fee
- Task parameters
- Callback function signature

> **CAUTION: Note on Funding Contracts**
>
> Making a GET request will fail unless your deployed contract has enough LINK to pay for it. **Learn how to [Acquire testnet LINK](/resources/acquire-link) and [Fund your contract](/resources/fund-your-contract)**.

```sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;

import {Chainlink, ChainlinkClient} from "@chainlink/contracts/src/v0.8/operatorforwarder/ChainlinkClient.sol";
import {ConfirmedOwner} from "@chainlink/contracts/src/v0.8/shared/access/ConfirmedOwner.sol";
import {LinkTokenInterface} from "@chainlink/contracts/src/v0.8/shared/interfaces/LinkTokenInterface.sol";

/**
 * Request testnet LINK and ETH here: https://faucets.chain.link/
 * Find information on LINK Token Contracts and get the latest ETH and LINK faucets here:
 * https://docs.chain.link/docs/link-token-contracts/
 */

/**
 * THIS IS AN EXAMPLE CONTRACT THAT USES HARDCODED VALUES FOR CLARITY.
 * THIS IS AN EXAMPLE CONTRACT THAT USES UN-AUDITED CODE.
 * DO NOT USE THIS CODE IN PRODUCTION.
 */
contract GetGasPrice is ChainlinkClient, ConfirmedOwner {
  using Chainlink for Chainlink.Request;

  uint256 public gasPriceFast;
  uint256 public gasPriceAverage;
  uint256 public gasPriceSafe;

  bytes32 private jobId;
  uint256 private fee;

  event RequestGasPrice(bytes32 indexed requestId, uint256 gasPriceFast, uint256 gasPriceAverage, uint256 gasPriceSafe);

  /**
   * @notice Initialize the link token and target oracle
   *
   * Sepolia Testnet details:
   * Link Token: 0x779877A7B0D9E8603169DdbD7836e478b4624789
   * Oracle: 0x6090149792dAAeE9D1D568c9f9a6F6B46AA29eFD (Chainlink DevRel)
   * jobId: 7223acbd01654282865b678924126013
   *
   */
  constructor() ConfirmedOwner(msg.sender) {
    _setChainlinkToken(0x779877A7B0D9E8603169DdbD7836e478b4624789);
    _setChainlinkOracle(0x6090149792dAAeE9D1D568c9f9a6F6B46AA29eFD);
    jobId = "7223acbd01654282865b678924126013";
    fee = (1 * LINK_DIVISIBILITY) / 10; // 0,1 * 10**18 (Varies by network and job)
  }

  /**
   * Create a Chainlink request the gas price from Etherscan
   */
  function requestGasPrice() public returns (bytes32 requestId) {
    Chainlink.Request memory req = _buildChainlinkRequest(jobId, address(this), this.fulfill.selector);
    // No need extra parameters for this job. Send the request
    return _sendChainlinkRequest(req, fee);
  }

  /**
   * Receive the responses in the form of uint256
   */
  function fulfill(
    bytes32 _requestId,
    uint256 _gasPriceFast,
    uint256 _gasPriceAverage,
    uint256 _gasPriceSafe
  ) public recordChainlinkFulfillment(_requestId) {
    emit RequestGasPrice(_requestId, _gasPriceFast, _gasPriceAverage, _gasPriceSafe);
    gasPriceFast = _gasPriceFast;
    gasPriceAverage = _gasPriceAverage;
    gasPriceSafe = _gasPriceSafe;
  }

  /**
   * Allow withdraw of Link tokens from the contract
   */
  function withdrawLink() public onlyOwner {
    LinkTokenInterface link = LinkTokenInterface(_chainlinkTokenAddress());
    require(link.transfer(msg.sender, link.balanceOf(address(this))), "Unable to transfer");
  }
}
```

To use this contract:

1. Open the [contract in Remix](https://remix.ethereum.org/#url=https://docs.chain.link/samples/APIRequests/GetGasPrice.sol).

2. Compile and deploy the contract using the Injected Provider environment. The contract includes all the configuration variables for the *Sepolia* testnet. Make sure your wallet is set to use *Sepolia*. The *constructor* sets the following parameters:
   - The Chainlink Token address for *Sepolia* by calling the [`setChainlinkToken`](/any-api/api-reference/#setchainlinktoken) function.
   - The Oracle contract address for *Sepolia* by calling the [`setChainlinkOracle`](/any-api/api-reference/#setchainlinkoracle) function.
   - The `jobId`: A specific job for the oracle node to run. In this case, the job is very specific to the use case as it returns the gas prices. You can find the job spec for the Chainlink node [here](/chainlink-nodes/job-specs/direct-request-existing-job).

3. Fund your contract with 0.1 LINK. To learn how to send LINK to contracts, read the [Fund Your Contracts](/resources/fund-your-contract) page.

4. Call the `gasPriceFast`, `gasPriceAverage` and `gasPriceSafe` functions to confirm that the `gasPriceFast`, `gasPriceAverage` and `gasPriceSafe` state variables are equal to zero.

5. Run the `requestGasPrice` function. This builds the `Chainlink.Request`. Note how succinct the request is.

6. After few seconds, call the `gasPriceFast`, `gasPriceAverage` and `gasPriceSafe` functions. You should get a non-zero responses.