Skip to content

Commit d1f9e38

Browse files
authored
update ton example (#29)
1 parent 6cea7c9 commit d1f9e38

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

price_feeds/ton/sdk_js_usage/package-lock.json

Lines changed: 7 additions & 7 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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"dependencies": {
2121
"@orbs-network/ton-access": "^2.3.3",
2222
"@pythnetwork/hermes-client": "^1.1.0",
23-
"@pythnetwork/pyth-ton-js": "^0.1.0",
23+
"@pythnetwork/pyth-ton-js": "^0.1.1",
2424
"@ton/core": "^0.59.0",
2525
"@ton/crypto": "^3.3.0",
2626
"@ton/ton": "^15.1.0",

price_feeds/ton/sdk_js_usage/src/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {HermesClient} from '@pythnetwork/hermes-client';
44
import {
55
PythContract,
66
PYTH_CONTRACT_ADDRESS_TESTNET,
7+
calculateUpdatePriceFeedsFee,
78
} from '@pythnetwork/pyth-ton-js';
89
import {getHttpEndpoint} from '@orbs-network/ton-access';
910

@@ -49,6 +50,8 @@ async function main() {
4950

5051
const updateFee = await contract.getUpdateFee(updateData);
5152
console.log('Update fee:', updateFee);
53+
const totalFee =
54+
calculateUpdatePriceFeedsFee(BigInt(updateFee)) + BigInt(updateFee);
5255

5356
const mnemonic = 'your mnemonic here';
5457
const key = await mnemonicToPrivateKey(mnemonic.split(' '));
@@ -66,7 +69,7 @@ async function main() {
6669
await contract.sendUpdatePriceFeeds(
6770
provider.sender(key.secretKey),
6871
updateData,
69-
BigInt(156000000) + BigInt(updateFee) // 156000000 = 390000 (estimated gas used for the transaction, this is defined in contracts/common/gas.fc as UPDATE_PRICE_FEEDS_GAS) * 400 (current settings in basechain are as follows: 1 unit of gas costs 400 nanotons)
72+
totalFee
7073
);
7174
console.log('Price feeds updated successfully.');
7275

0 commit comments

Comments
 (0)