Consume Price Feeds
Once your Rollup is deployed, all price feeds will automatically be ingested from the base layer by the Rollup every time a block is produced (every two seconds). Fresh prices are pushed to a predeploy oracle smart contract on the Rollup which exists at the following address:
L2PriceOracle
0x4200000000000000000000000000000000000420
Prices can be fetched by binding the L2PriceOracle
smart contract interface (below) to the predeploy address (above) or by simply inheriting from the provided Solidity SDK (recommended) which doesn't require an address to be specified.
Both methods return Pyth price objects. The type definition for this is available via the @pythnetwork/pyth-sdk-solidity
package on npm. See Using the Solidity SDK for more information.
Last updated