Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr-Electron authored Jan 29, 2024
1 parent 9fd90c5 commit 29308ea
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions docs/build/getting-started/oracles.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,14 @@ You can learn more about Pyth Oracles in their [official documentation](https://

You can use the following example code to get data from Pyth Oracles in Shimmer EVM:

:::note

The following example uses [`ether.js` v4](https://www.npmjs.com/package/ethers/v/4.0.43).

:::

```typescript
import {ethers} from "ethers";
import fetch from "node-fetch";

// Provider
const providerURL = "https://json-rpc.evm.shimmer.network"
const provider = new ethers.providers.JsonRpcProvider(providerURL);
const provider = new ethers.JsonRpcProvider(providerURL);

// Pyth Oracle contract on ShimmerEVM Mainnet
const contractAddress = '0xA2aa501b19aff244D90cc15a4Cf739D2725B5729';
Expand Down Expand Up @@ -108,7 +103,7 @@ async function getPrice() {
console.log('Price:', price);
console.log('Confidence Interval:', priceData.conf.toString());
// Convert publishTime to a formatted date
const publishTimeDate = new Date(priceData.publishTime.toNumber() * 1000);
const publishTimeDate = new Date(Number(priceData.publishTime) * 1000);
console.log('Publish Time:', publishTimeDate.toUTCString());
console.log('\n');
}
Expand All @@ -125,5 +120,4 @@ async function main() {
}
}

main();
```
main();

0 comments on commit 29308ea

Please sign in to comment.