How to get TON-bmTON rate
There are two ways to obtain TON-bmTON rate: on-chain and off-chain
The fundamental TON-bmTON rate is calculated using the formula:
bmTON rate = ton_total_supply / jetton_total_supply
On-chain:
To fetch ton_total_supply and jetton_total_supply on-chain, send a message to the Financial contract with the following TL-B layout:
// TL-B:
provide_current_quote#ad83913f
query_id:uint64
custom_payload:(Maybe ^Cell)
= InternalMsgBody;The Financial contract will respond with:
// TL-B
take_current_quote#0a420458
query_id:uint64
ton_total_supply:uint128
jetton_total_supply:uint128
custom_payload:(Maybe ^Cell)
= InternalMsgBody;Off-chain:
To retrieve ton_total_supply and jetton_total_supply you need to invoke 'get_full_data' method in Financial contract:
https://tonviewer.com/EQCSxGZPHqa3TtnODgMan8CEM0jf6HpY-uon_NMeFgjKqkEY?section=method
See the screenshot:

These two values 0x2524443fb29fa1 and 0x275f0f797cee6d are hexadecimal representations of jetton_total_supply and ton_total_supply . To convert them to decimal and compute the bmTON price, you can use the following code in Python:
Here is an example in Python:
Last updated