MoveVM
Using Connect Oracle
To query prices from Connect oracle on MoveVM, you need to use the oracle
module in InitiaStdLib found at 0x1::oracle
(explorer link).
This module provides a get_price
function that you can use to fetch the price of an asset pair. The asset pair is specified using the pair_id
, which is a string of the format "ASSET1/ASSET2"
. For example, the example module below fetches the price of BTC/USD from Connect oracle.
The response from the get_price
function is then a tuple of (price, timestamp, decimals)
, where:
price
is the price of the asset pair multiplied bytimestamp
is the timestamp of the last updatedecimals
is the number of decimals in the price
Was this page helpful?