Hi guys! When developing a contract
1. How can I get balance of ton of current contract?
2. How can I get balance of a jetton token of current contract by jetton minter address?
Sep 7, 2023, 9:37 AM
1: get_balance() https://docs.ton.org/develop/func/stdlib#get_balance
2. you can't. jettons are stored on separate contract for each user, and one contracts can't read info of other contracts. you can send msg, but response (if any) you'll process much later
2. you can't. jettons are stored on separate contract for each user, and one contracts can't read info of other contracts. you can send msg, but response (if any) you'll process much later
2* The only place where you can get balance of some jetton of some user is inside of contract for that jetton for that user. It's in get_data(), check jetton source code for more details.
Sep 7, 2023, 10:05 AM
asume that I write a contract and deploy it to the TON network, I use my account to send a Jetton to this contract -> Q1: Is it work?
If aswer of Q1 is "work", Q2: do we have any way for me to develop the contract to give it ability to transfer Jetton of this contract to another wallet?
Cmiiw
If aswer of Q1 is "work", Q2: do we have any way for me to develop the contract to give it ability to transfer Jetton of this contract to another wallet?
Cmiiw
Sep 7, 2023, 10:10 AM
It seems you have some gaps in jetton knowledge...
imagine this contracts:
JM - Jetton Master (Minter) - special contract
JA - Jetton Admin (who deployed JM) - regular wallet contract
JU - Jetton User (person who have some jettons) - regular wallet contract
JUW - Jetton (User) Wallet - special contract that "holds" jetton owned by some user. This contract is "tied" to JU. Every JU have his own JUW.
Initially JA deploys JM. There are no jettons in circulation (yet).
Then JA "mints" some jettons to some JU (including himself), sending special msg to JM. JM "creates" specified number of jettons, creates JUW (linked to JU) and transfers jettons to this JUW.
JUW "known" who is his JU and how many jettons he has. Only JUW have "true knowledge" about amount of jettons that JU has.
When JU wants to give some of his jettons to other user (JU2) - he sends from his JU message to his JUW with instruction to transfer some jettons to JU2. JUW(1) deploys JUW2 and transfers jettons.
Now JUW1 knows JU1 and amount of his jettons, and JUW2 known JU2 and his amount of jettons.
JM knowns only total amount of jettons it minted, but doesn't know what JUWs are holding them.
imagine this contracts:
JM - Jetton Master (Minter) - special contract
JA - Jetton Admin (who deployed JM) - regular wallet contract
JU - Jetton User (person who have some jettons) - regular wallet contract
JUW - Jetton (User) Wallet - special contract that "holds" jetton owned by some user. This contract is "tied" to JU. Every JU have his own JUW.
Initially JA deploys JM. There are no jettons in circulation (yet).
Then JA "mints" some jettons to some JU (including himself), sending special msg to JM. JM "creates" specified number of jettons, creates JUW (linked to JU) and transfers jettons to this JUW.
JUW "known" who is his JU and how many jettons he has. Only JUW have "true knowledge" about amount of jettons that JU has.
When JU wants to give some of his jettons to other user (JU2) - he sends from his JU message to his JUW with instruction to transfer some jettons to JU2. JUW(1) deploys JUW2 and transfers jettons.
Now JUW1 knows JU1 and amount of his jettons, and JUW2 known JU2 and his amount of jettons.
JM knowns only total amount of jettons it minted, but doesn't know what JUWs are holding them.
If above does not answer your question - please re-ask them :)
Sep 7, 2023, 10:39 AM
thank you so much, very transparent, I got the answer for my question
Sep 7, 2023, 10:40 AM