Price Feeds
in CosmWasm Contracts

Pyth on Cosmwasm

Cosmwasm contracts can update and fetch the Pyth prices using the Pyth Cosmwasm Contract, deployed on their network. The documented source code can be found here (opens in a new tab). The Cosmwasm API reference lets you interactively explore the complete API of the Pyth contract.

Update Price Feeds

The mechanism by which price feeds are updated on Cosmwasm is explained here. The @pythnetwork/price-service-client (opens in a new tab) typescript package can be used to fetch the latest price feed data which then can be passed to the contract as the UpdatePriceFeeds ExecuteMsg.

Pyth publishes prices for two kinds of feeds:

  1. Stable price feeds consist of prices generated on the pythnet blockchain. These feeds are available on both mainnet and testnet blockchains. Use stable feeds if you would like your test environment to be identical to your production environment.
  2. Edge price feeds consist of prices generated on the pythtest blockchain, which is Pyth's test environment for new features. Consequently, these feeds are not as reliable as the stable feeds, and there are other differences as well (e.g., different price feed ids). These feeds are only available on testnets.

Examples

Price Feed IDs

The price feed IDs for stable and edge feeds are different and can be found here.

Contract Addresses

Developers will need the address of the Pyth price feed contract on their blockchain in order to use Pyth. Please consult CosmWasm Contract Addresses to find the address for your blockchain.

Last updated on