You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pages/price-feeds/use-real-time-data/stacks.mdx
+13-13Lines changed: 13 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@ This guide explains how to use real-time Pyth data in [Clarity](https://clarity-
13
13
## Write Contract Code
14
14
15
15
The Pyth protocol integration for Stacks is available as a Beta on both testnet and mainnet networks, to help developers test, give feedback, and ensure the reliability and stability of the integration.
16
-
Unlike other smart contract languages, there is no importing modules into Clarity smart contracts for certain security reasons. So the Pyth integration on Stacks is implemented as its own set of Clarity contracts where developers will invoke a `contract-call?` to the main Pyth Clarity [contract](https://explorer.hiro.so/txid/SP3R4F6C1J3JQWWCVZ3S7FRRYPMYG6ZW6RZK31FXY.pyth-oracle-v3?chain=mainnet).
16
+
Unlike other smart contract languages, there is no importing modules into Clarity smart contracts for certain security reasons. So the Pyth integration on Stacks is implemented as its own set of Clarity contracts where developers will invoke a `contract-call?` to the main Pyth Clarity [contract](https://explorer.hiro.so/txid/SP1CGXWEAMG6P6FT04W66NVGJ7PQWMDAC19R7PJ0Y.pyth-oracle-v4?chain=mainnet).
17
17
18
18
<Callouttype="info"emoji="ℹ️">
19
19
Currently, the Pyth protocol integration is currently maintained by Trust
@@ -28,7 +28,7 @@ For our example, we will imagine a contract that mints an NFT in exchange for $1
28
28
29
29
<Callouttype="info"emoji="ℹ️">
30
30
The maintained Pyth integration contract for Stacks is called
After updating & verifying the price feed in question, and then getting the updated price feed data, we'll need to handle the price feed data and its properties.
65
-
The price feed data returned from invoking the `get-price` function of the `.pyth-oracle-v3` contract looks like the below:
65
+
The price feed data returned from invoking the `get-price` function of the `.pyth-oracle-v4` contract looks like the below:
66
66
67
67
```bash
68
68
{
@@ -114,11 +114,11 @@ We can then determine the USD amount of sBTC the user owns and decide if it is e
114
114
```
115
115
116
116
<Callouttype="warning"emoji="⚠️">
117
-
The `verify-and-update-price-feeds` of the `.pyth-oracle-v3` contract applies
117
+
The `verify-and-update-price-feeds` of the `.pyth-oracle-v4` contract applies
118
118
a fee of 1 uSTX, or 1 micro-stx, which is 0.000001 STX.
119
119
</Callout>
120
120
121
-
Alternatively, developers can just invoke the `read-price-feed` public function of the `pyth-oracle-v3.clar` contract. This will simply return the price feed from the last updated feed. But it's always encouraged to determine if a staleness check is viable for your application.
121
+
Alternatively, developers can just invoke the `read-price-feed` public function of the `pyth-oracle-v4.clar` contract. This will simply return the price feed from the last updated feed. But it's always encouraged to determine if a staleness check is viable for your application.
If you noticed, we set a post-condition statement of our user transferring less than or equal to 1 uSTX, which is 0.000001 STX. This is because the `verify-and-update-price-feeds` of the `.pyth-oracle-v3` contract applies a fee for this. Setting a separate post-condition statement on the actual sbtc token transfer in our example will also be needed. Beforehand, you could invoke the `decode-price-feeds` function with the `latestVaaHex` to simply have the contained price data decoded and returned. From there you could pre-determine the estimated amount of sbtc tokens to be transferred and set in a separate post-condition.
167
+
If you noticed, we set a post-condition statement of our user transferring less than or equal to 1 uSTX, which is 0.000001 STX. This is because the `verify-and-update-price-feeds` of the `.pyth-oracle-v4` contract applies a fee for this. Setting a separate post-condition statement on the actual sbtc token transfer in our example will also be needed. Beforehand, you could invoke the `decode-price-feeds` function with the `latestVaaHex` to simply have the contained price data decoded and returned. From there you could pre-determine the estimated amount of sbtc tokens to be transferred and set in a separate post-condition.
168
168
169
169
## Additional Resources
170
170
@@ -173,4 +173,4 @@ You may find these additional resources helpful for developing your Stacks appli
173
173
-**[Hiro Docs](https://docs.hiro.so/resources/guides/using-pyth-price-feeds):** Check out the dedicated guide for using Pyth in Stacks applications in Hiro's documentation. In this guide you'll see a visual architecture overview of using Pyth in Stacks, how you can test your implementation, how to fetch VAAs on the front-end, learn best practices, and more.
174
174
-**[Hiro How-To Tutorial](https://youtu.be/eybqQVRh_hw?si=KNfUp3RS3CnaST91):** Watch the dedicated video tutorial on using Pyth in Stacks and learn how a major Stacks DeFi app, Granite, is using Pyth.
175
175
-**[Trust Machine's Pyth Github](https://github.com/Trust-Machines/stacks-pyth-bridge):** Check out the open-source repo for the Pyth integration Clarity contracts.
176
-
-**[pyth-oracle-v3.clar](https://explorer.hiro.so/txid/SP3R4F6C1J3JQWWCVZ3S7FRRYPMYG6ZW6RZK31FXY.pyth-oracle-v3?chain=mainnet):** The latest Pyth integration contract on Stacks' mainnet.
176
+
-**[pyth-oracle-v4.clar](https://explorer.hiro.so/txid/SP1CGXWEAMG6P6FT04W66NVGJ7PQWMDAC19R7PJ0Y.pyth-oracle-v4?chain=mainnet):** The latest Pyth integration contract on Stacks' mainnet.
0 commit comments