Skip to content

Commit 258b2d1

Browse files
committed
feat: add IOTA testnet
1 parent 26bae47 commit 258b2d1

File tree

1 file changed

+8
-6
lines changed
  • pages/price-feeds/use-real-time-data

1 file changed

+8
-6
lines changed

pages/price-feeds/use-real-time-data/iota.mdx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ const priceIDs = [
106106

107107
const priceUpdateData = await connection.getPriceFeedsUpdateData(priceIDs);
108108

109-
// It is either injected from the browser or instantiated in the backend via some private key
109+
// It is either injected from the browser (https://www.npmjs.com/package/@iota/dapp-kit)
110+
// or instantiated in the backend via some private key (https://www.npmjs.com/package/@iota/iota-sdk)
110111
const wallet: SignerWithProvider = getWallet();
111112
// Get the state IDs of the Pyth and Wormhole contracts from
112113
// https://docs.pyth.network/price-feeds/contract-addresses/iota
@@ -126,14 +127,15 @@ tx.moveCall({
126127
});
127128

128129
const txBlock = {
129-
transactionBlock: tx,
130+
transaction: tx,
131+
wallet,
130132
options: {
131133
showEffects: true,
132134
showEvents: true,
133135
},
134136
};
135137

136-
const result = await wallet.signAndExecuteTransactionBlock(txBlock);
138+
const result = await wallet.signAndExecuteTransaction(txBlock);
137139
```
138140

139141
By calling the `updatePriceFeeds` function, the `IotaPythClient` adds the necessary transactions to the transaction block to update the price feeds.
@@ -142,9 +144,9 @@ By calling the `updatePriceFeeds` function, the `IotaPythClient` adds the necess
142144

143145
Your IOTA Move module **should NOT** have a hard-coded call to `pyth::update_single_price_feed.` In other words, a contract should **never call** the IOTA Pyth `pyth::update_single_price_feed` entry point. Instead, it should be called directly from client code (e.g., Typescript or Rust).
144146

145-
When IOTA contracts are [upgraded](<(https://docs.IOTA.io/build/package-upgrades)>), the address changes, which makes the old address no longer valid. If your module has a hard-coded call to `pyth::update_single_price_feed` living at a fixed call-site, it may eventually get bricked due to how Pyth upgrades are implemented. (Pyth only allow users to interact with the most recent package version for security reasons).
147+
When IOTA contracts are [upgraded](https://docs.iota.org/developer/iota-101/move-overview/package-upgrades/introduction), the address changes, which makes the old address no longer valid. If your module has a hard-coded call to `pyth::update_single_price_feed` living at a fixed call-site, it may eventually get bricked due to how Pyth upgrades are implemented. (Pyth only allow users to interact with the most recent package version for security reasons).
146148

147-
Therefore, you should build a [IOTA programmable transaction](https://docs.IOTA.io/build/prog-trans-ts-sdk) that first updates the price by calling `pyth::update_single_price_feed` at the latest call-site from the client-side and then call a function in your contract that invokes `pyth::get_price` on the `PriceInfoObject` to get the recently updated price.
149+
Therefore, you should build a [IOTA programmable transaction](https://docs.iota.org/developer/iota-101/transactions/ptb/programmable-transaction-blocks-overview) that first updates the price by calling `pyth::update_single_price_feed` at the latest call-site from the client-side and then call a function in your contract that invokes `pyth::get_price` on the `PriceInfoObject` to get the recently updated price.
148150
You can use `IOTAPythClient` to build such transactions and handle all the complexity of updating the price feeds.
149151

150152
Consult [Fetch Price Updates](../fetch-price-updates) for more information on how to fetch the `pyth_price_update`.
@@ -168,7 +170,7 @@ You can run this example with `npm run example-relay`. A full command that updat
168170
export IOTA_KEY=YOUR_PRIV_KEY;
169171
npm run example-relay -- --feed-id "5a035d5440f5c163069af66062bac6c79377bf88396fa27e6067bfca8096d280" \
170172
--hermes "https://hermes-beta.pyth.network" \
171-
--full-node "https://fullnode.testnet.IOTA.io:443" \
173+
--full-node "https://api.testnet.iota.cafe" \
172174
--pyth-state-id "0xd3e79c2c083b934e78b3bd58a490ec6b092561954da6e7322e1e2b3c8abfddc0" \
173175
--wormhole-state-id "0x31358d198147da50db32eda2562951d53973a0c0ad5ed738e9b17d88b213d790"
174176
```

0 commit comments

Comments
 (0)