-
Notifications
You must be signed in to change notification settings - Fork 37
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
Closed
Closed
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
c87cf5e
early draft
memearchivarius 2b5c5b1
Update gas-benchmarks.mdx
memearchivarius 64a3dbb
Merge branch 'main' into gas-usage
memearchivarius 176011f
remark
memearchivarius 5c22aae
Merge branch 'main' into gas-usage
memearchivarius 4f982b5
Merge branch 'main' into gas-usage
memearchivarius c3ef325
Update gas-benchmarks.mdx
memearchivarius cae1c21
Update gas-benchmarks.mdx
memearchivarius 5ba51cf
Update gas-benchmarks.mdx
memearchivarius 92a4943
Merge branch 'main' into gas-usage
memearchivarius da7fe9e
Update gas-benchmarks.mdx
memearchivarius 8318476
Merge branch 'main' into gas-usage
memearchivarius 99200cf
Changed the concept
memearchivarius b6a4787
Update gas-benchmarks.mdx
memearchivarius 1bad23c
Merge branch 'main' into gas-usage
memearchivarius 3f67ee6
Link-rot & remark
memearchivarius 4a49988
Merge branch 'main' into gas-usage
memearchivarius 22808bf
Update standard/wallets/gas-benchmarks.mdx
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| --- | ||
| title: "Cost comparison" | ||
| --- | ||
|
|
||
| import { Aside } from '/snippets/aside.jsx'; | ||
|
|
||
| <Aside | ||
| type="caution" | ||
| > | ||
| Gas costs can vary between different versions of TVM, keep that in mind. | ||
| </Aside> | ||
|
|
||
| This page provides comprehensive cost comparison for TON wallet contracts, presenting both gas consumption metrics and real-world costs in TON. The cost data includes all transaction fees, not just gas consumption, enabling users to make informed decisions based on their specific use cases. | ||
|
|
||
| ## Key findings by wallet type | ||
|
|
||
| | Version | Optimal batch size | Key advantage | | ||
| | :---------------- | :----------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| | [Wallet V3][v3] | ≤ 8 | Lowest cost for single and small batch transfers | | ||
| | [Wallet V4][v4] | ≤ 8 | Supports plugins | | ||
| | [Wallet V5][v5] | ≥ 8 | Most cost-effective for medium+ batches; <br /> [supports gasless transactions](/standard/wallets/v5#gasless-transactions) | | ||
| | [Highload V3][HL] | ≥ 20 | Less than 1% diff vs V5 after 128 messages; <br /> [parallel processing of messages](/standard/wallets/highload/overview#what-makes-them-different) | | ||
|
|
||
| ## Single transfers | ||
|
|
||
| | Wallet Version | Gas (units) | Cost (TON) | Cost per message (TON) | Difference | | ||
| | --------------- | ----------- | ---------- | ---------------------- | ------------------- | | ||
| | **V3** | 2,994 | 0.002217 | 0.002217 | Most cost-effective | | ||
| | **V4** | 3,308 | 0.002342 | 0.002342 | +5.67% vs V3 | | ||
| | **V5** | 4,939 | 0.003091 | 0.003091 | +39.42% vs V3 | | ||
| | **Highload V3** | 6,200 | 0.003599 | 0.003599 | +62.33% vs V3 | | ||
|
|
||
| ## Batch transfers (4 messages) | ||
|
|
||
| | Wallet Version | Gas (units) | Cost (TON) | Cost per message (TON) | Difference | | ||
| | --------------- | ----------- | ---------- | ---------------------- | ------------------- | | ||
| | **V3** | 4,920 | 0.0048448 | 0.001211 | Most cost-effective | | ||
| | **V4** | 5,234 | 0.0049704 | 0.001243 | +2.59% vs V3 | | ||
| | **V5** | 7,090 | 0.0059768 | 0.001494 | +23.38% vs V3 | | ||
| | **Highload V3** | 7,956 | 0.0082084 | 0.002052 | +69.45% vs V3 | | ||
|
|
||
| ## Batch transfers (8 messages) | ||
|
|
||
| V5 became more effective than V4 and almost tied with V3. | ||
|
|
||
| | Wallet Version | Gas (units) | Cost (TON) | Cost per message (TON) | Difference | | ||
| | --------------- | ----------- | ---------- | ---------------------- | ------------------- | | ||
| | **V3** | 9,840 | 0.0096896 | 0.001211 | Most cost-effective | | ||
| | **V5** | 9,958 | 0.0098248 | 0.001228 | +1.40% vs V3 | | ||
| | **V4** | 10,468 | 0.0099408 | 0.001243 | +2.59% vs V3 | | ||
| | **Highload V3** | 7,956 | 0.0120100 | 0.001501 | +23.95% vs V3 | | ||
|
|
||
| ## Batch transfers (16 messages) | ||
|
|
||
| Highload became more effective than V4 and almost tied with V3. | ||
|
|
||
| | Wallet Version | Gas (units) | Cost (TON) | Cost per message (TON) | Difference | | ||
| | --------------- | ----------- | ---------- | ---------------------- | ------------------- | | ||
| | **V5** | 15,694 | 0.0175432 | 0.001096 | Most cost-effective | | ||
| | **V3** | 19,680 | 0.0193792 | 0.001211 | +10.47% vs V5 | | ||
| | **Highload V3** | 7,956 | 0.0196580 | 0.001229 | +12.06% vs V5 | | ||
| | **V4** | 20,936 | 0.0198816 | 0.001243 | +13.34% vs V5 | | ||
|
|
||
| ## Batch transfers (20 messages) | ||
|
|
||
| Highload is significantly more effective than V3 or V4. | ||
|
|
||
| | Wallet Version | Gas (units) | Cost (TON) | Cost per message (TON) | Difference | | ||
| | --------------- | ----------- | ---------- | ---------------------- | ------------------- | | ||
| | **V5** | 18,562 | 0.0214040 | 0.001070 | Most cost-effective | | ||
| | **Highload V3** | 7,956 | 0.0234852 | 0.001174 | +9.72% vs V5 | | ||
| | **V3** | 24,600 | 0.0242240 | 0.001211 | +13.17% vs V5 | | ||
| | **V4** | 26,170 | 0.0248520 | 0.001243 | +16.11% vs V5 | | ||
|
|
||
| ## Batch transfers (200 messages) | ||
|
|
||
| V5 is still most effective, but difference is negligible. | ||
|
|
||
| | Wallet Version | Gas (units) | Cost (TON) | Cost per message (TON) | Difference | | ||
| | --------------- | ----------- | ---------- | ---------------------- | ------------------- | | ||
| | **V5** | 147,622 | 0.1954632 | 0.000977 | Most cost-effective | | ||
| | **Highload V3** | 7,956 | 0.1963556 | 0.000982 | +0.46% vs V5 | | ||
| | **V3** | 246,000 | 0.2422400 | 0.001211 | +23.93% vs V5 | | ||
| | **V4** | 261,700 | 0.2485200 | 0.001243 | +27.14% vs V5 | | ||
|
|
||
| <Aside> | ||
| Keep in mind that Highload V3 uses two transactions for batch transfers, which incur additional forward fee costs. | ||
| Also, actual gas consumption may vary between runs because the contract must process the existing dictionary state, while in the sandbox, each run usually starts from a clean state. | ||
| </Aside> | ||
|
|
||
| ## Methodology | ||
|
|
||
| ### Sandbox measurements: | ||
|
|
||
| Framework: Blueprint + [@ton/sandbox](/contract-dev/testing/overview) | ||
|
|
||
| Wallets: implementations from [@ton/ton](https://github.com/ton-org/ton) (V3R2, V4, V5R1) and [Highload V3 sources](https://github.com/ton-blockchain/highload-wallet-contract-v3) | ||
|
|
||
| Test scenario: Transfer 0.01 TON with `PAY_GAS_SEPARATELY` mode with unique comment for each message in batches to prevent deduplication. | ||
|
|
||
| ### On-chain measurements: | ||
|
|
||
| Network: TON testnet | ||
|
|
||
| Wallets: Same implementations as sandbox | ||
|
|
||
| Measurement: Actual transaction fees from explorer data | ||
|
|
||
| ## 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. | ||
|
|
||
| [v3]: /standard/wallets/history#wallet-v3 | ||
|
|
||
| [v4]: /standard/wallets/v4 | ||
|
|
||
| [v5]: /standard/wallets/v5 | ||
|
|
||
| [HL]: /standard/wallets/highload/overview | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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
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.
Also, why
tolk-benchin this article?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.
Because it's useful example of precise tests
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.
we don't want to provide more info than we need to, especially if it is not relevant to the case