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:
-
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.
-
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 theFastUpdatesConfiguration
contract address. Refer to the specific language guides for examples:
-
All examples in this guide are available at developer-hub/examples.
- web3.js
- ethers.js
- web3.py
- alloy-rs
- go-ethereum
This example user web3.js to retrieve FTSOv2 feed configurations on Flare Testnet Coston2.
npm install web3
// 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();
This example uses ethers.js to retrieve FTSOv2 feed configurations on Flare Testnet Coston2.
npm install ethers
// THIS IS EXAMPLE CODE. DO NOT USE THIS CODE IN PRODUCTION.
import { ethers } from "ethers";
// 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 provider = new ethers.JsonRpcProvider(RPC_URL);
// Set up contract instance
const ftsov2Config = new ethers.Contract(ADDRESS, JSON.parse(ABI), provider);
// Fetch feed configurations
const res = await ftsov2Config.getFeedConfigurations();
// 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;
}
This example uses web3.py to retrieve FTSOv2 feed configurations on Flare Testnet Coston2.
- uv
- pip
uv add web3
pip install web3
# THIS IS EXAMPLE CODE. DO NOT USE THIS CODE IN PRODUCTION.
import asyncio
from web3 import AsyncHTTPProvider, AsyncWeb3
# FastUpdatesConfiguration address (Flare Testnet Coston2)
# See https://dev.flare.network/ftso/solidity-reference
ADDRESS = "0xE7d1D5D58cAE01a82b84989A931999Cb34A86B14"
RPC_URL = "https://coston2-api.flare.network/ext/C/rpc"
# ABI for FastUpdatesConfiguration contract
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"}]}]}]' # noqa: E501
async def main() -> list:
# Connect to an RPC node
w3 = AsyncWeb3(
AsyncHTTPProvider(RPC_URL),
)
# Set up contract instance
ftsov2_config = w3.eth.contract(address=w3.to_checksum_address(ADDRESS), abi=ABI)
# Fetch feed configurations
feed_configurations = await ftsov2_config.functions.getFeedConfigurations().call()
# Print results
for feed_id, reward_band_value, inflation_share in feed_configurations:
print(
f"feedId: {feed_id.decode('ascii')}, "
f"rewardBandValue: {reward_band_value}, "
f"inflationShare: {inflation_share}"
)
return feed_configurations
if __name__ == "__main__":
asyncio.run(main())
This example uses alloy-rs to retrieve FTSOv2 feed configurations on Flare Testnet Coston2.
cargo add alloy eyre tokio --features alloy/full,tokio/rt,tokio/rt-multi-thread,tokio/macros
// THIS IS EXAMPLE CODE. DO NOT USE THIS CODE IN PRODUCTION.
use alloy::{providers::ProviderBuilder, sol};
use eyre::Result;
sol!(
#[sol(rpc)]
FastUpdatesConfiguration,
r#"[{"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"}]}]}]"#
);
#[tokio::main]
async fn main() -> Result<()> {
// FastUpdatesConfiguration address (Flare Testnet Coston2)
// See https://dev.flare.network/ftso/solidity-reference
let address = "0xE7d1D5D58cAE01a82b84989A931999Cb34A86B14".parse()?;
let rpc_url = "https://coston2-api.flare.network/ext/C/rpc".parse()?;
// Connect to an RPC node
let provider = ProviderBuilder::new().on_http(rpc_url);
// Set up contract instance
let ftsov2_config = FastUpdatesConfiguration::new(address, provider);
// Fetch feed configurations
let FastUpdatesConfiguration::getFeedConfigurationsReturn { _0 } =
ftsov2_config.getFeedConfigurations().call().await?;
// Print results
for feed in _0 {
println!(
"feedId: {}, rewardBandValue: {}, inflationShare: {}",
String::from_utf8(feed.feedId.as_slice().to_vec())?,
feed.rewardBandValue,
feed.inflationShare
);
}
Ok(())
}
This example uses the Go API from Geth to retrieve FTSOv2 feed configurations on Flare Testnet Coston2.
go get github.com/ethereum/go-ethereum/ethclient
With Go, you need to manually fetch the contract's ABI and generate the Go bindings. Copy the FastUpdatesConfiguration ABI and paste it into a file named FastUpdatesConfiguration.abi
, located in the root of your project, i.e. same level as go.mod
. Then using abigen, generate the Go bindings.
abigen --abi FastUpdatesConfiguration.abi --pkg main --type FastUpdatesConfiguration --out FastUpdatesConfiguration.go
// THIS IS EXAMPLE CODE. DO NOT USE THIS CODE IN PRODUCTION.
package main
import (
"context"
"fmt"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
)
func FtsoV2Config() {
// FastUpdatesConfiguration address (Flare Testnet Coston2)
// See https://dev.flare.network/ftso/solidity-reference
address := common.HexToAddress("0xE7d1D5D58cAE01a82b84989A931999Cb34A86B14")
rpcUrl := "https://coston2-api.flare.network/ext/C/rpc"
// Connect to an RPC node
client, _ := ethclient.Dial(rpcUrl)
// Set up contract instance
ftsov2, _ := NewFastUpdatesConfiguration(address, client)
// Fetch current feeds
opts := &bind.CallOpts{Context: context.Background()}
res, _ := ftsov2.GetFeedConfigurations(opts)
// Print results
for i := 0; i < len(res); i++ {
fmt.Printf("feedId: %s, rewardBandValue %d, inflationShare %d\n", string(res[i].FeedId[:]), res[i].RewardBandValue, res[i].InflationShare)
}
}