Lab 2: consume a Plugin-style price feed (mock on anvil, optional read-only fork)

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.

Steps

Exercises are the numbered comments in the starter files.

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).

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