Skip to main content

Query feed configuration

This guide provides code examples demonstrating how to read FTSOv2 feed configurations offchain using various programming languages. To achieve this, you need two key pieces of information:

  1. RPC Endpoint URL: The RPC Endpoint URL determines which network your code will interact with. You can either use a node provider service or point to your own RPC node. A list of public and private RPC endpoints for all Flare networks is available on the Network Configuration page.

  2. Contract Address: The address for the FastUpdatesConfiguration contract varies by network. You can obtain this address in two ways:

    • From the Solidity Reference page: Find the FastUpdatesConfiguration address for each network on the Solidity Reference page.

      OR

    • Query the FlareContractRegistry Contract: The FlareContractRegistry contract has the same address across all networks. You can query it to get the FastUpdatesConfiguration contract address. Refer to the specific language guides for examples:

tip

All examples in this guide are available at developer-hub/examples.

This example user web3.js to retrieve FTSOv2 feed configurations on Flare Testnet Coston2.

npm install web3
ftsov2_config.js
// THIS IS EXAMPLE CODE. DO NOT USE THIS CODE IN PRODUCTION.
import { Web3 } from "web3";

// FastUpdatesConfiguration address (Flare Testnet Coston2)
// See https://dev.flare.network/ftso/solidity-reference
const ADDRESS = "0xE7d1D5D58cAE01a82b84989A931999Cb34A86B14";
const RPC_URL = "https://coston2-api.flare.network/ext/C/rpc";
// ABI for FastUpdatesConfiguration contract
const ABI =
'[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"_governanceSettings","internalType":"contract IGovernanceSettings"},{"type":"address","name":"_initialGovernance","internalType":"address"},{"type":"address","name":"_addressUpdater","internalType":"address"}]},{"type":"event","name":"FeedAdded","inputs":[{"type":"bytes21","name":"feedId","internalType":"bytes21","indexed":true},{"type":"uint32","name":"rewardBandValue","internalType":"uint32","indexed":false},{"type":"uint24","name":"inflationShare","internalType":"uint24","indexed":false},{"type":"uint256","name":"index","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"FeedRemoved","inputs":[{"type":"bytes21","name":"feedId","internalType":"bytes21","indexed":true},{"type":"uint256","name":"index","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"FeedUpdated","inputs":[{"type":"bytes21","name":"feedId","internalType":"bytes21","indexed":true},{"type":"uint32","name":"rewardBandValue","internalType":"uint32","indexed":false},{"type":"uint24","name":"inflationShare","internalType":"uint24","indexed":false},{"type":"uint256","name":"index","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"GovernanceCallTimelocked","inputs":[{"type":"bytes4","name":"selector","internalType":"bytes4","indexed":false},{"type":"uint256","name":"allowedAfterTimestamp","internalType":"uint256","indexed":false},{"type":"bytes","name":"encodedCall","internalType":"bytes","indexed":false}],"anonymous":false},{"type":"event","name":"GovernanceInitialised","inputs":[{"type":"address","name":"initialGovernance","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"GovernedProductionModeEntered","inputs":[{"type":"address","name":"governanceSettings","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"TimelockedGovernanceCallCanceled","inputs":[{"type":"bytes4","name":"selector","internalType":"bytes4","indexed":false},{"type":"uint256","name":"timestamp","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"TimelockedGovernanceCallExecuted","inputs":[{"type":"bytes4","name":"selector","internalType":"bytes4","indexed":false},{"type":"uint256","name":"timestamp","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"addFeeds","inputs":[{"type":"tuple[]","name":"_feedConfigs","internalType":"struct IFastUpdatesConfiguration.FeedConfiguration[]","components":[{"type":"bytes21","name":"feedId","internalType":"bytes21"},{"type":"uint32","name":"rewardBandValue","internalType":"uint32"},{"type":"uint24","name":"inflationShare","internalType":"uint24"}]}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"cancelGovernanceCall","inputs":[{"type":"bytes4","name":"_selector","internalType":"bytes4"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"executeGovernanceCall","inputs":[{"type":"bytes4","name":"_selector","internalType":"bytes4"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IIFastUpdater"}],"name":"fastUpdater","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"_addressUpdater","internalType":"address"}],"name":"getAddressUpdater","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple[]","name":"","internalType":"struct IFastUpdatesConfiguration.FeedConfiguration[]","components":[{"type":"bytes21","name":"feedId","internalType":"bytes21"},{"type":"uint32","name":"rewardBandValue","internalType":"uint32"},{"type":"uint24","name":"inflationShare","internalType":"uint24"}]}],"name":"getFeedConfigurations","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes21","name":"_feedId","internalType":"bytes21"}],"name":"getFeedId","inputs":[{"type":"uint256","name":"_index","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes21[]","name":"_feedIds","internalType":"bytes21[]"}],"name":"getFeedIds","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"_index","internalType":"uint256"}],"name":"getFeedIndex","inputs":[{"type":"bytes21","name":"_feedId","internalType":"bytes21"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getNumberOfFeeds","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256[]","name":"","internalType":"uint256[]"}],"name":"getUnusedIndices","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"governance","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IGovernanceSettings"}],"name":"governanceSettings","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initialise","inputs":[{"type":"address","name":"_governanceSettings","internalType":"contract IGovernanceSettings"},{"type":"address","name":"_initialGovernance","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isExecutor","inputs":[{"type":"address","name":"_address","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"productionMode","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"removeFeeds","inputs":[{"type":"bytes21[]","name":"_feedIds","internalType":"bytes21[]"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"switchToProductionMode","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"allowedAfterTimestamp","internalType":"uint256"},{"type":"bytes","name":"encodedCall","internalType":"bytes"}],"name":"timelockedCalls","inputs":[{"type":"bytes4","name":"selector","internalType":"bytes4"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateContractAddresses","inputs":[{"type":"bytes32[]","name":"_contractNameHashes","internalType":"bytes32[]"},{"type":"address[]","name":"_contractAddresses","internalType":"address[]"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateFeeds","inputs":[{"type":"tuple[]","name":"_feedConfigs","internalType":"struct IFastUpdatesConfiguration.FeedConfiguration[]","components":[{"type":"bytes21","name":"feedId","internalType":"bytes21"},{"type":"uint32","name":"rewardBandValue","internalType":"uint32"},{"type":"uint24","name":"inflationShare","internalType":"uint24"}]}]}]';

export async function main() {
// Connect to an RPC node
const w3 = new Web3(RPC_URL);
// Set up contract instance
const ftsov2Config = new w3.eth.Contract(JSON.parse(ABI), ADDRESS);
// Fetch feed configurations
const res = await ftsov2Config.methods.getFeedConfigurations().call();
// Log results
for (const feed of res) {
console.log(
"feedId:",
Buffer.from(feed["feedId"].slice(2), "hex").toString("utf-8"),
"rewardBandValue:",
feed["rewardBandValue"],
"inflationShare:",
feed["inflationShare"],
);
}
return res;
}

main();