Time: ~50 min. Goal: read a Plugin (PLI) feed safely from a contract.
Plugin feeds on XDC expose the AggregatorV3-style read API (decimals(), latestRoundData()),
see src/interfaces/IPluginFeed.sol (copied from FeedKit, /kit/). Decimals differ per feed: most live feeds use 16 and some older ones 18 (and Plugin's contracts allow others, such as 25). Call decimals(), don't hard-code 8.
Exercises are the numbered comments in the starter files.
cd lab2 && forge install foundry-rs/forge-std@v1.17.0 --no-git && forge buildsrc/FeedConsumer.sol (checks: answer > 0, fresh, round complete; scale to 18 dp).test/FeedConsumer.t.sol using test/mocks/MockPluginFeed.sol.forge test -vv until green. XDC_FORK_RPC=https://rpc.xinfin.network forge test --match-path 'test/fork/*' -vv
Reads the live XDC/USDT feed (0x896C…6076, 16 dp). Some feeds revert "No access" (whitelisted).
anvil --port 18513, deploy MockPluginFeed + FeedConsumer with forge create using anvil test account #0, then cast call <consumer> "price18()(uint256)" --rpc-url anvil.
Discussion: why staleness per feed? (heartbeats differ: crypto ~1800 s, FX/equities 86400 s; see the FeedKit feed list, /kit/feeds.html).
Solution: lab2-solution.tar.gz (download link below; same layout, run the same forge install step first).
Download starter · Download solution · All workshop material