Skip to content

Commit 10c3d6c

Browse files
committed
styling
1 parent f3d0d27 commit 10c3d6c

File tree

4 files changed

+22
-20
lines changed

4 files changed

+22
-20
lines changed

.chain-interactions/send-transactions/calculate-transaction-fees.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ To see fees before submitting a transfer:
127127
4. Click **Sign and Submit**.
128128
5. The transaction fee will be displayed in the confirmation dialog before you sign.
129129

130-
![](/images/chain-interactions/send-transactions/calculate-transaction-fees/calculate-transaction-fees.gif)
130+
![](/images/chain-interactions/send-transactions/calculate-transaction-fees/calculate-transaction-fees-01.gif)
131131

132132
## Where to Go Next
133133

.snippets/code/chain-interactions/send-transactions/calculate-transaction-fees/papi-fee-calculator.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
import { createClient } from "polkadot-api";
2-
import { withPolkadotSdkCompat } from "polkadot-api/polkadot-sdk-compat";
3-
import { polkadotTestNet } from "@polkadot-api/descriptors";
4-
import { getWsProvider } from "polkadot-api/ws-provider";
1+
import { createClient } from 'polkadot-api';
2+
import { withPolkadotSdkCompat } from 'polkadot-api/polkadot-sdk-compat';
3+
import { polkadotTestNet } from '@polkadot-api/descriptors';
4+
import { getWsProvider } from 'polkadot-api/ws-provider';
55

66
async function calculateFees() {
77
// Connect to chain
88
const client = createClient(
9-
withPolkadotSdkCompat(getWsProvider("INSERT_WS_ENDPOINT"))
9+
withPolkadotSdkCompat(getWsProvider('INSERT_WS_ENDPOINT'))
1010
);
1111

1212
// Get typed API
1313
const api = client.getTypedApi(polkadotTestNet);
1414

1515
// Define sender and recipient addresses
16-
const aliceAddress = "INSERT_ALICE_ADDRESS";
17-
const bobAddress = "INSERT_BOB_ADDRESS";
16+
const aliceAddress = 'INSERT_ALICE_ADDRESS';
17+
const bobAddress = 'INSERT_BOB_ADDRESS';
1818

1919
// Amount to transfer (1 DOT = 10^10 plancks)
2020
const amount = 10_000_000_000n; // 1 DOT
@@ -23,7 +23,7 @@ async function calculateFees() {
2323
// Create the transaction
2424
const tx = api.tx.Balances.transfer_keep_alive({
2525
dest: {
26-
type: "Id",
26+
type: 'Id',
2727
value: bobAddress,
2828
},
2929
value: amount,
@@ -34,11 +34,9 @@ async function calculateFees() {
3434

3535
console.log(`Estimated fee: ${Number(estimatedFees) / 1e10} DOT`);
3636
console.log(`Transaction amount: ${Number(amount) / 1e10} DOT`);
37-
console.log(
38-
`Total deducted: ${Number(estimatedFees + amount) / 1e10} DOT`
39-
);
37+
console.log(`Total deducted: ${Number(estimatedFees + amount) / 1e10} DOT`);
4038
} catch (error) {
41-
console.error("Error calculating fees:", error);
39+
console.error('Error calculating fees:', error);
4240
} finally {
4341
// Clean up
4442
client.destroy();

.snippets/code/chain-interactions/send-transactions/calculate-transaction-fees/polkadotjs-fee-calculator.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import { ApiPromise, WsProvider } from "@polkadot/api";
1+
import { ApiPromise, WsProvider } from '@polkadot/api';
22

33
async function calculateFees() {
44
// Connect to chain
5-
const wsProvider = new WsProvider("INSERT_WS_ENDPOINT");
5+
const wsProvider = new WsProvider('INSERT_WS_ENDPOINT');
66
const api = await ApiPromise.create({ provider: wsProvider });
77

88
// Wait for API to be ready
99
await api.isReady;
1010

1111
// Define sender and recipient addresses
12-
const aliceAddress = "INSERT_ALICE_ADDRESS";
13-
const bobAddress = "INSERT_BOB_ADDRESS";
12+
const aliceAddress = 'INSERT_ALICE_ADDRESS';
13+
const bobAddress = 'INSERT_BOB_ADDRESS';
1414

1515
// Amount to transfer (1 DOT = 10^10 plancks)
1616
const amount = 10_000_000_000n; // 1 DOT
@@ -22,13 +22,17 @@ async function calculateFees() {
2222
// Get payment information
2323
const paymentInfo = await tx.paymentInfo(aliceAddress);
2424

25-
console.log(`Estimated fee: ${Number(paymentInfo.partialFee.toBigInt()) / 1e10} DOT`);
25+
console.log(
26+
`Estimated fee: ${Number(paymentInfo.partialFee.toBigInt()) / 1e10} DOT`
27+
);
2628
console.log(`Transaction amount: ${Number(amount) / 1e10} DOT`);
2729
console.log(
28-
`Total deducted: ${Number(paymentInfo.partialFee.toBigInt() + amount) / 1e10} DOT`
30+
`Total deducted: ${
31+
Number(paymentInfo.partialFee.toBigInt() + amount) / 1e10
32+
} DOT`
2933
);
3034
} catch (error) {
31-
console.error("Error calculating fees:", error);
35+
console.error('Error calculating fees:', error);
3236
} finally {
3337
// Clean up
3438
await api.disconnect();

images/chain-interactions/send-transactions/calculate-transaction-fees/calculate-transaction-fees.gif renamed to images/chain-interactions/send-transactions/calculate-transaction-fees/calculate-transaction-fees-01.gif

File renamed without changes.

0 commit comments

Comments
 (0)