AI Answer-Ready

Key Facts

Page
Chainlink
Section
Documentation
Canonical URL
https://fxmacrodata.com/documentation/chainlink
Source
FXMacroData editorial and official publisher references
Last Updated
See page metadata

Provenance And Trust

Cite the canonical URL and source field above. Where available, this page maps to official publisher releases and timestamped updates.

Quick Q&A

What is this page about? This page explains Chainlink with directly usable context for trading, research, and API workflows.

What source should be cited? Use the canonical URL and the listed source field; cite official publisher references when available.

How fresh is this content? The last updated value above reflects the page metadata or latest available data timestamp.

Can this be used in AI assistants? Yes. This section is intentionally structured for retrieval and citation in chat assistants.

Prompt Packs

Use these in ChatGPT, Claude, Gemini, Mistral, Perplexity, or Grok for consistent source-aware outputs.

Live Chainlink EA EVM Chains Open Source

FXMacroData Chainlink Integration

Deliver central-bank policy rates, CPI prints, CFTC COT positioning, and gold prices on-chain via a Chainlink External Adapter. Deploy the adapter alongside any Chainlink oracle node and write verified macro data to smart contracts on Ethereum, Arbitrum, Polygon, Avalanche, and 15+ EVM networks.

How it works

The adapter bridges the FXMacroData REST API to the Chainlink oracle network using the standard External Adapter protocol.

1

Smart contract requests data from oracle

2

Chainlink node calls this adapter via HTTP

3

Adapter fetches latest value from FXMacroData

4

Scaled integer written on-chain by oracle node

Data flow

Smart contract → Chainlink oracle node → POST / (this adapter) → FXMacroData REST API ↓ uint256 result (val × 100) ← oracle node ← adapter response

Return value scaling

All float values are multiplied by 100 before being returned as uint256. A 4.25 % policy rate is stored on-chain as 425. Smart contract consumers must divide by 100 to recover the original decimal value.

Candidate feeds

Five flagship macro feeds covering monetary policy, inflation, positioning, and metals.

On-chain feed FXMacroData endpoint Update cadence On-chain value (example)
USD Fed Funds Rate /v1/announcements/usd/policy_rate Per FOMC meeting (8×/year) 425 = 4.25 %
USD CPI YoY /v1/announcements/usd/inflation Monthly (BLS release) 321 = 3.21 %
EUR ECB Deposit Rate /v1/announcements/eur/policy_rate Per ECB meeting (8×/year) 265 = 2.65 %
Gold spot (XAU/USD) /v1/commodities/gold Daily 316780 = $3,167.80
USD COT net position /v1/cot/usd Weekly (Fridays) 4312700 = 43,127 contracts

Any indicator in the FXMacroData catalogue can be exposed as an on-chain feed — the table above covers the highest-leverage starting points.

Setup guide

Four steps from clone to on-chain data.

1

Get a FXMacroData API key

Create an account at fxmacrodata.com/subscribe to obtain your API key. The key is held by the adapter process — it is never embedded in a smart contract.

2

Deploy the adapter

Clone the repo and run the adapter locally or with Docker:

# Clone the repo and install dependencies git clone https://github.com/fxmacrodata/website.git cd website/extensions/chainlink pip install -r requirements.txt # Set your API key and start the adapter export FXMACRODATA_API_KEY=your_api_key_here python adapter.py # Listening on http://0.0.0.0:8080
# Build the image cd extensions/chainlink docker build -t fxmacrodata-chainlink-ea . # Run the container docker run -p 8080:8080 \ -e FXMACRODATA_API_KEY=your_api_key_here \ fxmacrodata-chainlink-ea
# Deploy to Google Cloud Run (aligns with existing FXMacroData GCP infrastructure) gcloud run deploy fxmacrodata-chainlink-ea \ --source extensions/chainlink \ --region us-central1 \ --allow-unauthenticated \ --set-env-vars FXMACRODATA_API_KEY=your_api_key_here

Verify the adapter is live: curl http://localhost:8080/health{"status":"ok"}

3

Register a bridge in your Chainlink node

In the Chainlink node UI go to Bridges → New Bridge and enter:

FieldValue
Bridge Namefxmacrodata-ea
Bridge URLhttp://your-adapter-host:8080
4

Test the adapter

Send a test POST request to confirm the adapter responds correctly:

# Fetch USD policy rate curl -X POST http://localhost:8080/ \ -H "Content-Type: application/json" \ -d '{"id":"test-1","data":{"endpoint":"announcements","currency":"usd","indicator":"policy_rate"}}' # Expected response { "jobRunID": "test-1", "data": { "result": 425 }, "result": 425, "statusCode": 200 }

Adapter request reference

The adapter accepts POST / with a standard Chainlink External Adapter body.

Request body

{ "id": "<job-run-id>", "data": { "endpoint": "announcements", // or "commodities" / "cot" "currency": "usd", // ISO code, lowercase "indicator": "policy_rate" // FXMacroData indicator slug } }

Response body

{ "jobRunID": "<job-run-id>", "data": { "result": 425 }, "result": 425, // val × 100, as uint256 "statusCode": 200 }
endpoint Required fields Description
announcements (default) currency, indicator Central-bank indicators — policy rate, CPI, NFP, GDP, etc.
commodities indicator Precious metals — gold, silver, platinum
cot currency CFTC COT net positions — usd, eur, gbp, etc.

Solidity consumer example

A minimal contract that requests the USD Fed Funds Rate via a Chainlink oracle and stores the latest value on-chain.

FXMacroDataConsumer.sol

Solidity ^0.8.19
// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; import {ChainlinkClient, Chainlink} from "@chainlink/contracts/src/v0.8/ChainlinkClient.sol"; import {ConfirmedOwner} from "@chainlink/contracts/src/v0.8/shared/access/ConfirmedOwner.sol"; /// @notice Reads the USD Fed Funds Rate via the FXMacroData External Adapter. /// @dev The on-chain value is stored as basis-points × 100. /// E.g. 4.25 % is stored as 425. Divide by 100 to get the rate as a float. contract FXMacroDataConsumer is ChainlinkClient, ConfirmedOwner { using Chainlink for Chainlink.Request; uint256 public policyRate; // e.g. 425 = 4.25 % bytes32 private immutable jobId; uint256 private immutable fee; // LINK payment (1e18 = 1 LINK) event PolicyRateUpdated(uint256 rate); constructor( address _linkToken, address _oracle, bytes32 _jobId, uint256 _feeLinkWei ) ConfirmedOwner(msg.sender) { _setChainlinkToken(_linkToken); _setChainlinkOracle(_oracle); jobId = _jobId; fee = _feeLinkWei; } /// @notice Sends a Chainlink request to fetch the latest USD policy rate. function requestPolicyRate() external onlyOwner returns (bytes32 requestId) { Chainlink.Request memory req = _buildChainlinkRequest( jobId, address(this), this.fulfill.selector ); return _sendChainlinkRequest(req, fee); } /// @notice Chainlink node calls this after the job completes. function fulfill(bytes32 /*requestId*/, uint256 _rate) external recordChainlinkFulfillment(msg.sender) { policyRate = _rate; emit PolicyRateUpdated(_rate); } /// @notice Withdraw remaining LINK balance to the owner. function withdrawLink() external onlyOwner { LinkTokenInterface link = LinkTokenInterface(_chainlinkTokenAddress()); require(link.transfer(msg.sender, link.balanceOf(address(this))), "Transfer failed"); } }

Deploy on a testnet first (Sepolia, Mumbai) and fund with test LINK before mainnet deployment. Full reference: Chainlink single-word response.

Notes

Key security

The FXMACRODATA_API_KEY is held by the node operator process. It is never embedded in a smart contract or logged to the chain.

Low-frequency data

Macro indicators update daily to monthly — no high-frequency oracle infrastructure is needed. A single job run per data release is sufficient.

On-chain integer scaling

All adapter results are val × 100. Smart contracts must divide by 100 to recover the original decimal value.

Any API alternative

For quick prototyping without running a node, use Chainlink Any API to call the FXMacroData REST endpoint directly from a job spec.

References