Price Feeds
UpdatePriceFeeds

Update Price Feeds

Update the on-chain price feeds using the provided data, which contains serialized and signed price update data from Pyth Network. You can retrieve the latest price data for a given set of price feeds from the Hermes API (opens in a new tab). Executing this message updates the on-chain price if the provided update is more recent than the current on-chain price. Otherwise, the provided update will be ignored. Execution will succeed even if the update is ignored.

This operation requires the caller to pay a fee to perform the update. The required fee for a given set of updates can be computed using the GetUpdateFee query.

Reverts if the required fee is not paid, or the data is incorrectly signed or formatted.

ArgumentInputDescription

data*

vec<Binary>

The price update data for the contract to verify.

fee*

Coin

The update fee expressed in the minimal native coin denomination.
Examples

Example Code

import { DirectSecp256k1HdWallet, coin } from '@cosmjs/proto-signing';
import { SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate';
import { GasPrice } from '@cosmjs/stargate';
 
const wallet = await DirectSecp256k1HdWallet.fromMnemonic('your mnemonic here');
 
// neutron
const cosmwasmClient = await SigningCosmWasmClient.connectWithSigner(
  'https://rpc-voidara.neutron-1.neutron.org',
  wallet,
  {
    gasPrice: GasPrice.fromString('0.1untrn'),
  }
);
 
const address = (await wallet.getAccounts())[0].address;
const txResponse = await cosmwasmClient.execute(
  address,
  'neutron1m2emc93m9gpwgsrsf2vylv9xvgqh654630v7dfrhrkmr5slly53spg85wv',
  {
    'update_price_feeds': {
      'data': ['<data>']
    }
  },
  'auto',
  '',
  [coin(<fee>, 'untrn')]
);
 
Last updated on