-
Notifications
You must be signed in to change notification settings - Fork 76
Add estimate fee tx #1279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: staging/product-ia
Are you sure you want to change the base?
Add estimate fee tx #1279
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds comprehensive documentation and code examples for calculating transaction fees on Polkadot-based chains. It provides practical examples using both Polkadot-API (PAPI) and Polkadot.js API, along with instructions for the Polkadot-JS Apps UI.
Key Changes:
- Complete tutorial documentation covering fee calculation concepts and prerequisites
- TypeScript code examples for both PAPI and Polkadot.js API with detailed explanations
- Expected output samples demonstrating fee estimation results
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
.chain-interactions/send-transactions/calculate-transaction-fees.md |
Main tutorial document explaining transaction fee calculation with three different approaches (PAPI, Polkadot.js API, and UI) |
.snippets/code/chain-interactions/send-transactions/calculate-transaction-fees/polkadotjs-fee-calculator.ts |
Polkadot.js API implementation for fee estimation |
.snippets/code/chain-interactions/send-transactions/calculate-transaction-fees/polkadotjs-fee-calculator-output.html |
Expected terminal output for the Polkadot.js API example |
.snippets/code/chain-interactions/send-transactions/calculate-transaction-fees/papi-fee-calculator.ts |
PAPI implementation for fee estimation |
.snippets/code/chain-interactions/send-transactions/calculate-transaction-fees/papi-fee-calculator-output.html |
Expected terminal output for the PAPI example |
π‘ Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const bobAddress = "INSERT_BOB_ADDRESS"; | ||
|
|
||
| // Amount to transfer (1 DOT = 10^10 plancks) | ||
| const amount = 1_000_000_000_000n; // 1 DOT |
Copilot
AI
Nov 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment states "1 DOT = 10^10 plancks" and the amount is set to 1_000_000_000_000n (1 trillion), but 10^10 is 10 billion, not 1 trillion. The value should be 10_000_000_000n to represent 1 DOT, or the comment should state "1 DOT = 10^12 plancks" if 1 trillion is correct.
| const amount = 1_000_000_000_000n; // 1 DOT | |
| const amount = 10_000_000_000n; // 1 DOT |
| const bobAddress = "INSERT_BOB_ADDRESS"; | ||
|
|
||
| // Amount to transfer (1 DOT = 10^10 plancks) | ||
| const amount = 1_000_000_000_000n; // 1 DOT |
Copilot
AI
Nov 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment states "1 DOT = 10^10 plancks" and the amount is set to 1_000_000_000_000n (1 trillion), but 10^10 is 10 billion, not 1 trillion. The value should be 10_000_000_000n to represent 1 DOT, or the comment should state "1 DOT = 10^12 plancks" if 1 trillion is correct.
| const amount = 1_000_000_000_000n; // 1 DOT | |
| const amount = 10_000_000_000n; // 1 DOT |
| To see fees before submitting a transfer: | ||
|
|
||
| 1. Navigate to **Accounts** > **Accounts** in the top menu | ||
| 2. Choice an account and click **send** |
Copilot
AI
Nov 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: "Choice" should be "Choose".
| 2. Choice an account and click **send** | |
| 2. Choose an account and click **send** |
| <span data-ty>Transaction amount: 100 DOT</span> | ||
| <span data-ty>Total deducted: 100.0014668864 DOT</span> |
Copilot
AI
Nov 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The output shows "Transaction amount: 100 DOT", but the code sets the amount to 1_000_000_000_000n which, based on the conversion factor used (/ 1e10), would output 100 DOT. However, the comment in the code states this is "1 DOT". Either the comment should say "100 DOT" or the amount should be 10_000_000_000n for 1 DOT (assuming 10^10 plancks per DOT).
| <span data-ty>Transaction amount: 100 DOT</span> | |
| <span data-ty>Total deducted: 100.0014668864 DOT</span> | |
| <span data-ty>Transaction amount: 1 DOT</span> | |
| <span data-ty>Total deducted: 1.0014668864 DOT</span> |
| <span data-ty>Transaction amount: 100 DOT</span> | ||
| <span data-ty>Total deducted: 100.0014668864 DOT</span> |
Copilot
AI
Nov 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The output shows "Transaction amount: 100 DOT", but the code sets the amount to 1_000_000_000_000n which, based on the conversion factor used (/ 1e10), would output 100 DOT. However, the comment in the code states this is "1 DOT". Either the comment should say "100 DOT" or the amount should be 10_000_000_000n for 1 DOT (assuming 10^10 plancks per DOT).
| <span data-ty>Transaction amount: 100 DOT</span> | |
| <span data-ty>Total deducted: 100.0014668864 DOT</span> | |
| <span data-ty>Transaction amount: 1 DOT</span> | |
| <span data-ty>Total deducted: 1.0014668864 DOT</span> |
π Description
Provide a clear and concise description of your changes.
π Review Preference
Choose one:
π€ AI-Ready Docs
If content changed, regenerate AI files:
python3 scripts/generate_llms.pyβ Checklist