Skip to content

Commit 6cea7c9

Browse files
authored
update ton example (#28)
1 parent 244f8a4 commit 6cea7c9

File tree

3 files changed

+134
-3
lines changed

3 files changed

+134
-3
lines changed

price_feeds/ton/sdk_js_usage/package-lock.json

Lines changed: 117 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

price_feeds/ton/sdk_js_usage/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
"posttest": "npm run lint"
1919
},
2020
"dependencies": {
21-
"@pythnetwork/pyth-ton-js": "^0.1.0",
21+
"@orbs-network/ton-access": "^2.3.3",
2222
"@pythnetwork/hermes-client": "^1.1.0",
23+
"@pythnetwork/pyth-ton-js": "^0.1.0",
2324
"@ton/core": "^0.59.0",
2425
"@ton/crypto": "^3.3.0",
2526
"@ton/ton": "^15.1.0",

price_feeds/ton/sdk_js_usage/src/index.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,23 @@ import {
55
PythContract,
66
PYTH_CONTRACT_ADDRESS_TESTNET,
77
} from '@pythnetwork/pyth-ton-js';
8+
import {getHttpEndpoint} from '@orbs-network/ton-access';
89

910
const BTC_PRICE_FEED_ID =
1011
'0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43';
1112

1213
async function main() {
14+
const endpoint = await getHttpEndpoint({
15+
network: 'testnet',
16+
});
1317
const client = new TonClient({
14-
endpoint: 'https://testnet.toncenter.com/api/v2/jsonRPC',
15-
apiKey: 'your-api-key-here', // Optional, but note that without api-key you need to send requests once per second
18+
endpoint,
1619
});
20+
// You can also try to create a client with an API key with Toncenter if the previous one fails
21+
// const client = new TonClient({
22+
// endpoint: 'https://testnet.toncenter.com/api/v2/jsonRPC',
23+
// apiKey: 'your-api-key-here', // Optional, but note that without api-key you need to send requests once per second
24+
// });
1725

1826
const contractAddress = Address.parse(PYTH_CONTRACT_ADDRESS_TESTNET);
1927
const contract = client.open(PythContract.createFromAddress(contractAddress));
@@ -50,6 +58,11 @@ async function main() {
5058
});
5159
const provider = client.open(wallet);
5260

61+
// If this fails, check that you have enough TON on your wallet
62+
// - parse the BoC to get the dest_address
63+
// - console.log(loadMessage(Cell.fromBase64("your-boc-here").beginParse()
64+
// - check the balance of the dest_address
65+
// - get testnet TON from Testgiver TON Bot: https://t.me/testgiver_ton_bot
5366
await contract.sendUpdatePriceFeeds(
5467
provider.sender(key.secretKey),
5568
updateData,

0 commit comments

Comments
 (0)