-
Notifications
You must be signed in to change notification settings - Fork 71
Gas comparison between wallets for simple transfers #537
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
Changes from 12 commits
c87cf5e
2b5c5b1
64a3dbb
176011f
5c22aae
4f982b5
c3ef325
cae1c21
5ba51cf
92a4943
da7fe9e
8318476
99200cf
b6a4787
1bad23c
3f67ee6
4a49988
22808bf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,178 @@ | ||
| --- | ||
| title: "Gas benchmarks" | ||
| --- | ||
|
|
||
| import { Aside } from '/snippets/aside.jsx'; | ||
|
|
||
| <Aside | ||
| type="caution" | ||
| > | ||
| On-chain TVM global version 12, sandbox TVM global version 11. | ||
| </Aside> | ||
|
|
||
| This page provides gas consumption benchmarks for TON wallet contracts,\ | ||
|
memearchivarius marked this conversation as resolved.
Outdated
|
||
| measured in both sandbox (local testing) and on-chain (testnet) environments. | ||
|
|
||
| ## Single transfers | ||
|
|
||
| Gas costs vary between sandbox and on-chain due to different VM configurations, but the relative comparison between wallet versions remains consistent. | ||
|
|
||
| | Wallet Version | Sandbox (gas) | On-chain (gas) | Notes | | ||
| | --------------- | ------------- | -------------------- | --------------------------------------------- | | ||
| | **V3** | 2,994 | [2,494][V3-single] | Baseline, most efficient for single transfers | | ||
| | **V4** | 3,308 | [2,808][V4-single] | +10% vs V3, adds plugin support | | ||
| | **V5** | 4,939 | [4,439][V5-single] | +65% vs V3, supports gasless & batch | | ||
| | **Highload V3** | 6,200 | [6,200][HLv3-single] | +107% vs V3, but highly efficient for batches | | ||
|
memearchivarius marked this conversation as resolved.
Outdated
|
||
|
|
||
| [HLv3-single]: https://testnet.tonviewer.com/transaction/e4a5bc1851b709260146999dd402fc7e6640b98505536b127fea3dcd9d46086d | ||
|
|
||
| [HLv3-batch]: https://testnet.tonviewer.com/transaction/ad6298ff8edf063224bc54a34a39294a44f4a0595e65d73ff4c3511f9f37dacb | ||
|
|
||
| [V5-single]: https://testnet.tonviewer.com/transaction/6677ea2a3d0cdccf335bb9856089e8c8986a9a7ff08cbafb8bcb4c8b768bb82e | ||
|
|
||
| [V5-batch]: https://testnet.tonviewer.com/transaction/3337c38f131d336b2b7462207cdee1af9171873ec5958ea4565051064a1de4eb | ||
|
|
||
| [V4-single]: https://testnet.tonviewer.com/transaction/bb8cfe3748c30e36d63c28871829d0e6dc9f6fdfd715f0623c1f563249737045 | ||
|
|
||
| [V3-single]: https://testnet.tonviewer.com/transaction/427c5ace7a87c968510daeea2b53a34f56dc9a4ae0397213047d8bcbf51cfed7 | ||
|
|
||
| ## Batch transfers | ||
|
|
||
| | Wallet Version | Sandbox (gas) | On-chain (gas) | Notes (12 messages are chosen for simplicity) | | ||
| | --------------- | ------------- | ------------------- | ----------------------------------------------------------------------------------------------------- | | ||
| | **V3** | 14,760 | - | Supports [up to 4 messages](/standard/wallets/history#external-message-body-layout-3) per transaction | | ||
|
memearchivarius marked this conversation as resolved.
Outdated
|
||
| | **V5** | 11,392 | [10,892][V5-batch] | Efficient with batch compared to V3/V4 | | ||
| | **Highload V3** | 7,956 | [7,911][HLv3-batch] | Less gas, but uses 2 transactions for batch | | ||
|
memearchivarius marked this conversation as resolved.
Outdated
|
||
|
|
||
| ### Total cost | ||
|
|
||
| | Wallet Version | Single Transfer | 4 Messages | 12 Messages | 50 Messages | | ||
| | --------------- | --------------- | -------------------------------------------------------------------- | ---------------------------------------------------------------------- | ------------- | | ||
| | **V3** | 0.0022648 TON | 0.0048448 TON | <Tooltip tip="Untested, approximated by hand.">0.0145344 TON</Tooltip> | N/A | | ||
|
memearchivarius marked this conversation as resolved.
Outdated
memearchivarius marked this conversation as resolved.
Outdated
memearchivarius marked this conversation as resolved.
Outdated
|
||
| | **V4** | 0.0023872 TON | 0.0049704 TON | <Tooltip tip="Untested, approximated by hand.">0.0149112 TON</Tooltip> | N/A | | ||
| | **V5** | 0.0031356 TON | 0.0059768 TON | 0.0137208 TON | 0.05052 TON | | ||
| | **Highload V3** | 0.0036404 TON | <Tooltip tip="Untested, approximated by hand.">\~0.025 TON</Tooltip> | 0.0158308 TON | 0.0521892 TON | | ||
|
memearchivarius marked this conversation as resolved.
Outdated
|
||
|
|
||
| <Aside> | ||
| Keep in mind that Highload V3 is using two transactions for batch transfers, this incur additional fwd fee costs. | ||
| For example, if we use 12 messages for simplicity, total cost is: | ||
|
|
||
| `0.0137208 TON` for Wallet V5 (1 transaction with 12 messages).\ | ||
| `0.0145344 TON` for Wallet V3 (3 transactions with 4 messages each).\ | ||
| `0.0158308 TON` for Highload V3 (2 transactions with 12 messages). | ||
| </Aside> | ||
|
|
||
| **Key insights:** | ||
|
memearchivarius marked this conversation as resolved.
Outdated
|
||
|
|
||
| - V5 has higher gas overhead for single transfers (+65% vs V3) but becomes efficient with batch operations. Supports up to 255 messages per transaction. | ||
| - Highload V3 is expensive for single transfers but becomes highly efficient at scale: | ||
| - Gas cost doesn't change with the number of messages in a batch | ||
| - 100 messages: \~79 gas/msg | ||
| - Designed for handling thousands of transactions | ||
|
|
||
| ```json expandable | ||
|
memearchivarius marked this conversation as resolved.
Outdated
|
||
| "Wallet V3 batch 4 messages": { | ||
| "gas": 4920, | ||
| "compute_fee_nanoton": 1968000, | ||
| "storage_fee_nanoton": 0, | ||
| "import_fee_nanoton": 1276800, | ||
| "total_fwd_fees_nanoton": 1600000, | ||
| "forward_only_nanoton": 1066676, | ||
| "action_fee_nanoton": 533324, | ||
| "total_fee_nanoton": 3778124, | ||
| "reported_total_nanoton": 3778124, | ||
| "true_network_total_nanoton": 4844800, | ||
| "transactions": 1 | ||
| } | ||
|
|
||
| "Wallet V5 batch 12 messages": { | ||
| "gas": 12826, | ||
| "compute_fee_nanoton": 5130400, | ||
| "storage_fee_nanoton": 0, | ||
| "import_fee_nanoton": 3790400, | ||
| "total_fwd_fees_nanoton": 4800000, | ||
| "forward_only_nanoton": 3200028, | ||
| "action_fee_nanoton": 1599972, | ||
| "total_fee_nanoton": 10520772, | ||
| "reported_total_nanoton": 10520772, | ||
| "true_network_total_nanoton": 13720800, | ||
| "transactions": 1 | ||
| } | ||
|
|
||
| "Highload V3 batch 12 messages": { | ||
| "gas": 7956, | ||
| "compute_fee_nanoton": 3182400, | ||
| "storage_fee_nanoton": 0, | ||
| "import_fee_nanoton": 4096400, | ||
| "total_fwd_fees_nanoton": 8552000, | ||
| "forward_only_nanoton": 5701381, | ||
| "action_fee_nanoton": 2850619, | ||
| "total_fee_nanoton": 10129419, | ||
| "reported_total_nanoton": 10129419, | ||
| "true_network_total_nanoton": 15830800, | ||
| "transactions": 2 | ||
| } | ||
| ``` | ||
|
|
||
| ## Methodology | ||
|
|
||
| #### Sandbox measurements: | ||
|
memearchivarius marked this conversation as resolved.
Outdated
memearchivarius marked this conversation as resolved.
Outdated
|
||
|
|
||
| Framework: Blueprint + @ton/sandbox\ | ||
|
memearchivarius marked this conversation as resolved.
Outdated
|
||
| Wallets: implementations from **@ton/ton** (V3R2, V4, V5R1) | ||
|
memearchivarius marked this conversation as resolved.
Outdated
|
||
| and [Highload V3 sources](https://github.com/ton-blockchain/highload-wallet-contract-v3)\ | ||
| Test scenario: Simple transfer of 0.01 TON with `PAY_GAS_SEPARATELY` mode | ||
|
|
||
| #### On-chain measurements: | ||
|
|
||
| Network: TON testnet\ | ||
| Wallets: Same implementations as sandbox\ | ||
| Measurement: Actual transaction gas consumption from explorer data | ||
|
|
||
| <Aside type="note"> | ||
| Absolute gas numbers may vary slightly due to: | ||
|
|
||
| - VM configuration differences (sandbox vs on-chain) | ||
|
memearchivarius marked this conversation as resolved.
Outdated
|
||
| - Message size or the way you construct the message | ||
|
|
||
| The relative comparison between wallet versions remains consistent across environments. | ||
| </Aside> | ||
|
|
||
| ## Use case recommendations | ||
|
|
||
| Based on cost-effectiveness: | ||
|
|
||
| **For retail users (1-10 transactions/day):** | ||
|
memearchivarius marked this conversation as resolved.
Outdated
|
||
|
|
||
| - Use **V3** or **V4** — most cost-effective for single transfers (2,994 gas baseline) | ||
|
memearchivarius marked this conversation as resolved.
Outdated
|
||
| - V5 adds 65% gas overhead for single transfers but provides modern features | ||
| - Total cost difference negligible for low volume; choose based on feature needs | ||
|
|
||
| **For moderate volume (10-100 transactions/day):** | ||
|
|
||
| - Use **V5** for batch operations — 6% savings vs V3 for 12-message batches | ||
| - Single V5 batch (255 msgs) more efficient than multiple V3/V4 batches | ||
| - V5 supports up to 255 messages per transaction vs V3/V4 limit of 4 | ||
|
|
||
| **For high volume (100+ transactions/day):** | ||
|
|
||
| - **Highload V3** becomes efficient with large batches | ||
| - Designed for exchanges and payment processors (different processing approach) | ||
| - Gas cost remains constant regardless of batch size (unlike V3/V4/V5) | ||
| - **Note:** Uses 2-transaction approach resulting in \~1.8x higher forward fees | ||
|
|
||
| **Gas comparison for batching:** | ||
|
|
||
| - Highload V3: 7956 gas per batch (flat cost regardless of batch size) | ||
| - V5: \~1,069 gas/message for 12 messages (scales down with larger batches) | ||
| - V3/V4: \~1,230 gas/message (limited to 4 messages per batch) | ||
|
|
||
| ## Code examples | ||
|
|
||
| Check [gas-research](https://github.com/memearchivarius/gas-research) and [tolk-bench](https://github.com/ton-blockchain/tolk-bench) projects for code examples. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should move the scripts to https://github.com/ton-org/docs-examples, there should be no links to personal repos in the docs, unless it's some kind of SDK which happens to live there
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, why
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because it's useful example of precise tests
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we don't want to provide more info than we need to, especially if it is not relevant to the case |
||
|
|
||
| **Key features of the gas-research testing suite:** | ||
|
|
||
| - Comprehensive gas and fee breakdown analysis | ||
| - Automated benchmarking across all wallet versions | ||
| - Fee calculation helpers for precise cost analysis | ||
Uh oh!
There was an error while loading. Please reload this page.