Using Solidity SDK
Easily fetch oracle prices from a Solidity smart contract using the SDK.
The Solidity SDK handles binding the oracle interface to the predeploy address under the hood. With this abstracted away, you can simply inherit from the L2PriceOracle
smart contract exported by the SDK and call any of the methods from the API Reference.
An example integration of the Solidity SDK can be found in Templates & Examples.
Installation
To add the Solidity SDK to an existing package run the following:
Installing pyth-sdk-solidity
is required since the L2PriceOracle
smart contract follows the Pyth interface and returns PythStructs.Price
objects.
Integration
Reading price feeds from the oracle via the methods documented in the API Reference is as simple as importing and inheriting from the L2PriceOracle
smart contract exported by SDK.
Methods exposed by the inherited L2PriceOracle
smart contract are prefixed with an underscore for clarity since they are internal. When calling methods from the API Reference, be sure to prefix the method name with an underscore.
Last updated