Flux docs
Search…
FPO Requesters
Test your protocol's contracts with our consistent, high quality data provision on NEAR, Aurora, & Evmos.

Before Getting Started

Check out our list of available data feeds to see if we already have you covered. If we don't have your feed yet, reach out to us on telegram to talk integrations!

Get Requesting

You should have an account set up on the chain you're requesting on, and should have a contract set up to receive the data if you plan to use it for your protocol.
NEAR
EVM Chains
Check out our implementation of the NEAR FPO here. The following is an excerpt of the functions you will use as a protocol, and some example queries to request them.
When inputting pairs and providers, be sure to use the format QUOTE/BASE without any spaces in between.
Example: "{\"pair\": \"NEAR/USD\", \"provider\": \"amberdata.testnet\"}"
The pairs & providers that you can choose from are listed in the FPO Live Networks & Pairs page. Simply combine the quote with the base token in all capital letters in the pair section, then input the provider[s] you wish to collect the data from.

Interact from CLI

To interact with the Near FPO, you can run one of the following commands, replacing YOUR_ACCOUNT_ID with your actual account_id.
Method
Arguments
Example
Description
Output Example
get_entry
pair: String, provider: AccountId
near call fpo.opfilabs.testnet get_entry "{\"pair\": \"NEAR/USD\", \"provider\": \"opfilabs.testnet\"}" --accountId NEAR_TESTNET_ACCOUNT.testnet
Get latest update for a requested price pair from a requested provider
{ price: '11851000', decimals: 6, last_update: 1651246559312501500 }
aggregate_avg
pairs: String, providers: AccountId min_last_update: U64
near call fpo.opfilabs.testnet aggregate_avg "{"pairs": ["NEAR/USD", "NEAR/USD"], "providers": ["opfilabs.testnet", "opfilabs.testnet"], "min_lastupdate": 1644957121}" --accountId ACCOUNT_ID.testnet
Returns average of latest updates for requested price pairs from selected providers within the last update timestamp
'1183631610'
aggregate_collect
pairs: String, providers: AccountId min_last_update: U64
near call fpo.opfilabs.testnet aggregate_collect "{"pairs": ["NEAR/USD", "NEAR/USD"], "providers": ["opfilabs.testnet", "opfilabs.testnet"], "min_lastupdate": 1644957121}" --accountId ACCOUNT_ID.testnet
Returns list of latest updates for requested price pairs from from selected providers within the last update timestamp
[ '1178686581', '1178686581' ]
aggregate_median
pairs: String, providers: AccountId min_last_update: U64
near call fpo.opfilabs.testnet aggregate_median "{"pairs": ["NEAR/USD", "NEAR/USD"], "providers": ["opfilabs.testnet", "opfilabs.testnet"], "min_lastupdate": 1644957121}" --accountId ACCOUNT_ID.testnet
Returns median of latest updates for requested price pairs from selected providers within the last update timestamp
'1184141459'

Interact from Contract (using cross contract call)

It's a bit complicated to configure your code for a cross contract call, but we have provided an example of how this is done here Follow the directions in the README to set it up, deploy, and test it out!
To get started, clone our FPO EVM repository. Select a contract from one of our contracts deployed to your EVM chain to choose which price pair to request, then run the following command, replacing CONTRACT_ADDRESS with one of the addresses that are live here, and the NETWORK_NAME with the name of the network you're deploying on:
1
yarn latestAnswer --contract CONTRACT_ADDRESS --network NETWORK_NAME
Copied!
The networks and their configurations can be found here, for instance goerli or aurora-testnet.

Requester Cross Contract Call Example

You can find a sample contract that can make cross contract calls to the EVM FPO here. We've copied the code below for your viewing pleasure.
1
// SPDX-License-Identifier: MIT
2
pragma solidity ^0.8.10;
3
4
import "./interface/CLV2V3Interface.sol";
5
import "@openzeppelin/contracts/access/AccessControl.sol";
6
7
contract ExamplePriceFeedConsumer is AccessControl {
8
bytes32 public constant OWNER_ROLE = keccak256("OWNER_ROLE");
9
CLV2V3Interface public priceFeed;
10
11
constructor(address _priceFeed) {
12
_setupRole(OWNER_ROLE, msg.sender);
13
priceFeed = CLV2V3Interface(_priceFeed);
14
}
15
16
/// @notice Fetches the latest price from the price feed
17
function getLatestPrice() public view returns (int256) {
18
return priceFeed.latestAnswer();
19
}
20
21
/// @notice Changes price feed contract address
22
/// @dev Only callable by the owner
23
function setPriceFeed(address _priceFeed) public onlyRole(OWNER_ROLE) {
24
priceFeed = CLV2V3Interface(_priceFeed);
25
}
26
}
Copied!
To execute a cross contract call, run the following command, replacing PRICE_FEED_CONTRACT_ADDRESS with the price feed contract you're looking to connect to.
1
npx hardhat deploy:ExamplePriceFeedConsumer --price-feed PRICE_FEED_CONTRACT_ADDRESS
Copied!
Export as PDF
Copy link