circle-info
This is the first version of our Documentation, it will be improved and extended soon.
Page cover

Get Your First Price (On-Chain)

Fetching a price from IFÁ Labs is simple and fully on-chain. We'll walk through two easy methods: using Remix IDE (no local setup required) and directly via Basescan (block explorer).

Choose the one that fits your workflow; both work on the Base mainnet or testnet.

  1. Create a new file (e.g., PriceConsumer.sol) and paste the following code:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IIfaPriceFeed {
    struct PriceFeed {
        int256 price;
        int8 decimal;
        uint256 lastUpdateTime;
    }
    
    function getAssetInfo(bytes32 assetId) external view returns (PriceFeed memory assetInfo, bool exists);
}

contract PriceReader {
    IIfaPriceFeed public constant feed = IIfaPriceFeed(0xA9F17344689C2c2328F94464998db1d3e35B80dC); // Base Mainnet
    
    // Example: USDT/USD asset ID
    bytes32 public constant USDT_ASSET_ID = 0x6ca0cef6107263f3b09a51448617b659278cff744f0e702c24a2f88c91e65a0d;
    
    function getUSDTPrice() external view returns (int256 price, int8 decimal, uint256 timestamp, bool exists) {
        (IIfaPriceFeed.PriceFeed memory info, bool _exists) = feed.getAssetInfo(USDT_ASSET_ID);
        return (info.price, info.decimal, info.lastUpdateTime, _exists);
    }
}
  1. Compile the contract (Solidity compiler ≥0.8.0).

  2. In the "Deploy & Run Transactions" tab:

    • Environment: Injected Provider (connect MetaMask to Base).

    • Deploy the PriceReader contract (costs a tiny amount of gas).

    • Call getUSDTPrice() — you'll see the raw price, decimal (typically -18), timestamp, and existence flag.

Interpreting the Result:

  • Human-readable price = price / 10 ** (-decimal)

  • For stablecoins, expect ≈1.00 USD (e.g., raw price ≈ 1e18 for decimal -18).

Method 2: Directly on Basescan (No Coding Needed)

  1. Connect your wallet if prompted.

  2. Find getAssetInfo function.

  3. Enter an asset ID (e.g., USDT/USD: 0x6ca0cef6107263f3b09a51448617b659278cff744f0e702c24a2f88c91e65a0d).

  4. Click "Query" — results appear instantly.

Common Asset IDs (Mainnet & Testnet)

Asset
Asset ID

USDT/USD

0x6ca0cef6107263f3b09a51448617b659278cff744f0e702c24a2f88c91e65a0d

USDC/USD

0xf989296bde68043d307a2bc0e59de3445defc5f292eb390b80d78162c8a6b13d

CNGN/USD

0x83a18c73cf75a028a24b79cbedb3b8d8ba363b748a3210ddbcaa95eec3b87b3a

BRZ/USD

0xbc60b55b031dce1ee5679098bf2f35d66a94a566124e2b233324d2bafcc6d5b5

You've just fetched your first onchain price from IFÁ Labs!

Next: Learn how to Verify Price Integrity for production-grade safety.

Last updated

Was this helpful?