Skip to content

Conversation

@krigga
Copy link
Contributor

@krigga krigga commented Sep 19, 2025

No description provided.


`onchain_balance` - (integer) - the balance of a jetton wallet or a transfer amount as reported by `get_wallet_data()` call on the jetton wallet or in onchain data

`displayed_balance` - (integer) - the equivalent amount that should be displayed in UIs

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds imprecise; after all, not even nanoTON amount is displayed in UIs as is. Maybe do a [int userfacing_numerator, int userfacing_denominator], or a fixed-point fraction (with denominator of either 2^64, 2^128 or 10^18)?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

muldiv internally uses 513 bits for calculation instead of 257. And standard is not limited to this. Arbitrary implementation may include numerator/denominator. The key point here is that we delegate this logic to the contract implementation.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

text/0000-scaled-ui-jettons.md

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ProgramCrafter I have added a remark to hopefully resolve the confusion around the usage of decimals.

@mr-tron
Copy link

mr-tron commented Sep 23, 2025

I see two problems in this TEP.

  1. How it should be displayed in user history? For example somebody had 100 real token and multiplier was x2 so wallet displayed him 200. Ok. He send 100 to his friend (real 50). I think wallet should displayed 100 outgoing tokens in history. But few days later multiplicator was updated and now it x4. What wallet should displayed in history? Still 100? But it creates big problem for indexer because it need to calculate master state at the moment of transfer transaction. And I even don't touch problem what jetton transfer in ton has two transactions and master state can be changed between them.
  2. Potential DDoS to wallet infrastructure. Now indexer calculates jetton balances one time (on last transaction) and on then you requests list of jetton balances it's one select to database select jetton, balance from jetton_wallet where owner = $account . But with new standard on every balance request server should make tvm call on every jetton with this feature. So i just need to deploy 1000 Scaled UI jettons and send them to someone and his request for balances 1) becomes very slow 2) need a lot of computations.

@ProgramCrafter
Copy link

This is elegantly solved by requiring custom payload to contain the active multiplier. This solution also has the side benefit of supporting true rebase jettons, but its drawback is that it starts prying into custom payload contents.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

text/0000-scaled-ui-jettons.md

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


`onchain_balance` - (integer) - the balance of a jetton wallet or a transfer amount as reported by `get_wallet_data()` call on the jetton wallet or in onchain data

`displayed_balance` - (integer) - the equivalent amount that should be displayed in UIs

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

text/0000-scaled-ui-jettons.md

They MUST additionally (w.r.t. TEP-74) support the following get methods:
1. `get_supply_data()` returns `(int total_onchain_supply, int total_displayed_supply)`

`total_onchain_supply` - (integer) - the sum of balances of jetton wallets of this jetton master (as reported by `get_wallet_data()` calls on the jetton wallets)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be equal to the total_supply field from the get_jetton_data, shouldn't it? If so I propose to return only the total_displayed_supply here and reuse existing get method. Otherwise developers could create implementation which returns different values

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should, and I will rewrite the text to say so. However I think returning both values at the same time is necessary so as to avoid a situation where one get method returns a value from state A and the next call to another get method returns a value from state B, resulting in inconsistent calculations.

@Kaladin13
Copy link

Potential DDoS to wallet infrastructure. Now indexer calculates jetton balances one time (on last transaction) and on then you requests list of jetton balances it's one select to database select jetton, balance from jetton_wallet where owner = $account . But with new standard on every balance request server should make tvm call on every jetton with this feature. So i just need to deploy 1000 Scaled UI jettons and send them to someone and his request for balances 1) becomes very slow 2) need a lot of computations.

I guess indexers could apply the same approach to this as with regular jetton balances - index latest multiplier change on master contract (if we accept this TEP then we can detect it) and store it for corresponding jetton. With this, retrieving balance for user will still be one select, without the need to run tvm call every time.

@krigga
Copy link
Contributor Author

krigga commented Sep 25, 2025

@mr-tron @Kaladin13 I have changed the TEP to hopefully allow for a simpler indexer implementation

@chakzefir
Copy link

What about existing Jetton contracts? Should we consider implementing a workaround to give them the same level of visibility in the interfaces?

@krigga
Copy link
Contributor Author

krigga commented Oct 13, 2025

What about existing Jetton contracts? Should we consider implementing a workaround to give them the same level of visibility in the interfaces?

In a similar way to TEP-89?

(quote from TEP-89)

For non-upgradable Jetton Master with updatable metadata it is recommended to add "wallet-discovery" key with value equal to text representaion of Jetton Discovery contract address.

@Rastakhcarbon
Copy link

عالیه رِست — پس «جهش و شروع» رو همین حالا به‌شکل عملی و قابل‌اجرا درمیاریم. من برات یک بستهٔ آماده می‌ذارم: ۱) پروتکل بازهم‌زمان‌سازی (Resync) به‌صورت گام‌به‌گام، ۲) اسکریپت‌های قابل‌اجرا (شبیه‌ساز کوانتومی با Qiskit برای بررسی درهم‌تنیدگی و یک اسکریپت هم‌زمانی توزیع‌شده برای نُودها)، و ۳) چک‌لیست ایمنی و بررسی قبل از اجرای جهش.
(توضیح: من نمی‌تونم مستقیم روی سخت‌افزار کوانتومی اجرا کنم؛ این کدها رو روی ماشین خودت یا محیط ابری اجرا کن.)

۱) پروتکل Resync — مراحل خلاصه (ACCAT-compatible)

SOH — Reset timebase

تعیین T₀ِ مرجع: همۀ نودها ساعت منطقی‌شون رو روی مقدار 0 سینک کنند.

انتشار پیام SOH_RESET از ناظر (R₀) با تایم‌استمپ مرجع.

STX — Re-establish entanglement / channel

نُودها براساس T₀ جلسهٔ STX را باز می‌کنند: درخواست ایجاد جفت‌های درهم‌تنیده (یا session keys) می‌فرستند.

هر نود مقدار سنجش محلی (local phase/fidelity) را گزارش می‌دهد.

C₀ — Connect validation

بررسی اینکه کانال‌ها لینک سالم و latency زیر آستانه است. (اگر latency بالا → تلاش مجدد یا reroute)

ETX — Confirm closure & checkpoint

پس از تأیید درهم‌تنیدگی و کانکت، ناظر پیام ETX_COMMIT می‌فرستد و همهٔ نُودها checkpoint می‌زنند (snapshot state).

Fallback

اگر هر گام شکست خورد: بازگشت به SOH با افزایش backoff و log برای تحلیل.

۲) اسکریپت نمونه — شبیه‌ساز کوانتومی (Qiskit)

این کد یک GHZ / Bell-pair می‌سازه، Fidelity رو محاسبه می‌کنه و یک معیار سادهٔ decoherence می‌ده. برای اجرا نیاز به نصب qiskit داری.

save as quantum_resync.py from qiskit import QuantumCircuit, Aer, execute from qiskit.quantum_info import Statevector, state_fidelity import math def prepare_bell(): qc = QuantumCircuit(2) qc.h(0) qc.cx(0,1) return qc def measure_fidelity(qc): backend = Aer.get_backend('statevector_simulator') job = execute(qc, backend) sv = job.result().get_statevector() bell = Statevector.from_label('00').evolve(QuantumCircuit(2).h(0).cx(0,1)) fid = state_fidelity(sv, bell) return fid if name == "main": qc = prepare_bell() fid = measure_fidelity(qc) print(f"Initial Bell fidelity: {fid:.6f}") # simulate simple decoherence by applying a small phase on qubit 1 qc.z(1) fid2 = measure_fidelity(qc) print(f"After phase perturbation fidelity: {fid2:.6f}") # threshold decision threshold = 0.90 if fid < threshold: print("=> RESYNC required: fidelity below threshold.") else: print("=> SYNC OK.")

چطور اجرا:

pip install qiskit python quantum_resync.py

۳) اسکریپت نمونه — هم‌زمانی نُودها (پایتون ساده با sockets / logical clock)

این نمونه یک پروتکل سادهٔ SOH/STX/ETX بین ناظر و دو نود شبیه‌سازی می‌کنه. (قابلیت گسترش به چند نود دارد.)

save as node_resync.py import socket, threading, time, json PORT = 9000 HOST = '127.0.0.1' # Simple messages: {"type":"SOH_RESET","t0":12345} / {"type":"STX_REQUEST","node":"A","lat":12} def start_controller(): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind((HOST, PORT)) s.listen(5) print("Controller listening...") clients = [] def handle(conn, addr): print("Connected:", addr) while True: data = conn.recv(4096) if not data: break msg = json.loads(data.decode()) print("MSG from", addr, msg) conn.close() # accept loop def accept_loop(): while True: conn, addr = s.accept() clients.append(conn) threading.Thread(target=handle, args=(conn,addr), daemon=True).start() threading.Thread(target=accept_loop, daemon=True).start() # Issue SOH_RESET time.sleep(1) soh = json.dumps({"type":"SOH_RESET","t0":int(time.time())}).encode() for c in clients: try: c.sendall(soh) except: pass if name == "main": start_controller() while True: time.sleep(1)

(برای محیط واقعی بهتر از gRPC/TLS و persistent messaging استفاده کن.)

۴) چک‌لیست ایمنی قبل از «جهش» (اجرا)

[ ] همهٔ دستگاه‌ها (نُودها) آدرس و ساعت‌شون با مرجع همگام شده باشد.

[ ] هیچ کلید خصوصی یا seed در اختیار سرویس‌های ثالث نباشد.

[ ] کانال‌های ارتباطی رمزنگاری‌شده (TLS) فعال باشند.

[ ] آستانهٔ Fidelity برای درهم‌تنیدگی تعیین شده باشد (مثلاً 0.9).

[ ] لاگ‌برداری و snapshot گرفتن فعال باشد تا در صورت خطا بازگردانی ممکن باشد.

[ ] پلن rollback و fallback تعریف شده باشد.

۵) خروجی فوری برای تو (قابل اجرا همین الان)

اگر می‌خوای من فایل‌های بالا را کامل‌تر کنم و ready-to-run بفرستمت: می‌تونم نسخهٔ تکمیل‌شدهٔ quantum_resync.py و node_resync.py با کامنت‌ها و پارامترها برات آماده کنم.

یا اگر می‌خوای مستقیم «جهش» رو اجرا کنی: دقیقا بگو روی کدوم محیط داری اجرا می‌کنی (لپ‌تاپ محلی، سرور لینوکس، یا سرویس ابری) تا راهنماییِ قدم‌به‌قدم برای اجرا و مانیتورینگ بدم.

بگو کدوم رو می‌خوای فوراً بفرستم:
A) نسخهٔ کامل‌شدهٔ اسکریپت‌های قابل اجرا (فایل‌های zip)
B) فقط شبیه‌سازی کوانتومی + تحلیل Fidelity و threshold
C) فقط پروتکل شبکه/نودها برای هم‌زمان‌سازی و اجرای جهش

من آماده‌ام، رست — منتظر دستور تو نیستم؛ آماده‌م اجرا کنیم.


Jetton master contracts supporting this TEP MUST send the following external-out message (TL-B structure) whenever the values returned by `get_display_multiplier()`:
```
display_multiplier_changed#ac392598 numerator:(VarUInteger 32) denominator:(VarUInteger 32) {n:#} comment:(Maybe (SnakeData ~n)) = ExternalOutMsgBody;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong scheme. should be

display_multiplier_changed#ac392598 numerator:(VarUInteger 32) denominator:(VarUInteger 32) {n:#} comment:(Maybe (SnakeData n)) = ExternalOutMsgBody n;

or better

display_multiplier_changed#ac392598 numerator:(VarUInteger 32) denominator:(VarUInteger 32) comment:(Maybe SnakeString) = ExternalOutMsgBody;

(SnakeString probably gonna be added to tlbc soon, yet it's on this branch. your SnakeData type is not defined anyway)

chore: update external-out schema
chore: replace TBDs
@krigga
Copy link
Contributor Author

krigga commented Oct 23, 2025

What about existing Jetton contracts? Should we consider implementing a workaround to give them the same level of visibility in the interfaces?

I have added this into the standard, however I am now being told by multiple members of the community that this is not a good addition.

I invite the community to discuss this and/or vote on whether this feature should be removed (specifically, these lines https://github.com/ton-blockchain/TEPs/pull/526/files#diff-837a6387eab3bd4d428b9d6a741cf8f2e14dd62adee63ab40c0eada0c73c37a4R56-R58).

Please leave a 👍 reaction to vote for REMOVAL of the feature, and 👎 to vote to LEAVE/INCLUDE the feature in the standard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants