How to use real-time data in TON contracts
Pyth is a pull oracle. Pyth price feeds on TON are managed through the main TON Pyth smart contract, enabling seamless interaction with on-chain data. In TON, these interactions are facilitated by specific functions within the Pyth TON contract. This contract acts as an interface to Pyth price feeds, handling the retrieval and updating of price data.Install the Pyth SDK
Install the Pyth TON SDK and other necessary dependencies using npm or yarn:Write code to interact with oracle
Off-chain data fetch and update
The following code snippet demonstrates how to fetch price updates, interact with the Pyth contract on TON, and update price feeds:- TON Mainnet:
EQA5NPyjfZztDm8jcTBwTAU9NGsgJEkw19z61yecX0TlseSB - TON Testnet:
EQBeydTZBuv4nkqN8jkScqZbWcyx7TsmOtxsEDbFann0IRtD
PYTH_CONTRACT_ADDRESS_TESTNET to PYTH_CONTRACT_ADDRESS_MAINNET accordingly.