Neon Labs
Published in

Neon Labs

Pyth on Neon EVM: Real-time Market Data Oracle

Decentralized Finance (DeFi) has been revolutionizing the way people around the world interact with their money. Many of its innovative capabilities are based on its ability to integrate high-fidelity, time-sensitive, real-world data, including data from off-chain sources.

This data is typically supplied by oracles, entities that feed external data to a blockchain. That’s where Pyth comes in.

Pyth is an open-source, real-time on-chain market data feed that supports the Neon EVM. Pyth currently supports price feed for select cryptocurrency, foreign exchange, precious metal, and equity pairs, and its source code is publicly available on GitHub.

How to Use Pyth With the Neon EVM

Let’s dive into how to make Pyth price feeds available for your Neon dApp. We’ll do this by considering a simple smart contract involving Pyth on the Neon EVM.

Before we begin, It is important to note that the Pyth team strongly recommends its users to follow its consumer best practices when consuming Pyth data.

In the following simple Solidity smart contract, the function getBTCUSDPrice() returns the price from the BTC/USD price feed for the Neon Devnet. For a different price feed, refer to the Pyth website for both Devnet and Mainnet, find the price feed, and use the corresponding price feed ID (the priceID variable below). Alternatively, you could also search for your desired price feed here.

Price Feed IDs offered by Pyth Network for Neon EVM Devnet

How to Deploy

To deploy your smart contract with Pyth oracle integration using Truffle, follow these steps:

  1. Create a .secret file containing the private key or mnemonic of the account you want to use to deploy the contracts.
  2. Optional: Edit the truffle-config.js file to add the Neon network you want to deploy to.
  3. Run truffle migrate — network neon_devnet


Pyth plays a crucial role in the Neon ecosystem. By providing a feed of high-quality external data, it allows for accurate and real-time asset pricing on the Neon EVM. Without this oracle, activities such as decentralized swaps on Neon would be impossible. With Pyth, developers on Neon can make their smart contracts work even smarter.

First, add the necessary Pyth imports.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store