1- using System . Net ;
2- using Microsoft . Extensions . Logging ;
3- using TonLibDotNet . Cells ;
1+ using Microsoft . Extensions . Logging ;
42using TonLibDotNet . Types ;
53using TonLibDotNet . Types . Msg ;
64
75namespace TonLibDotNet . Samples . Recipes
86{
97 public class Jettons : ISample
108 {
11- const string jettonMasterAddress = "EQBbX2khki4ynoYWgXqmc7_5Xlcley9luaHxoSE0-7R2whnK" ;
9+ // some testnet jetton
10+ const string jettonMinterAddressTestnet = "EQBbX2khki4ynoYWgXqmc7_5Xlcley9luaHxoSE0-7R2whnK" ;
1211
1312 // regular wallet, not jetton one!
14- const string ownerWalletAddress = "EQAkEWzRLi1sw9AlaGDDzPvk2_F20hjpTjlvsjQqYawVmdT0" ;
13+ const string ownerWalletAddressTestnet = "EQAkEWzRLi1sw9AlaGDDzPvk2_F20hjpTjlvsjQqYawVmdT0" ;
14+
15+ // jUSDT
16+ const string jettonMinterAddressMainnet = "EQBynBO23ywHy_CgarY9NK9FTz0yDsG82PtcbSTQgGoXwiuA" ;
17+
18+ // regular wallet, not jetton one!
19+ const string ownerWalletAddressMainnet = "EQB3ncyBUTjZUA5EnFKR5_EnOMI9V1tTEAAPaiU71gc4TiUt" ;
1520
1621 // regular wallet, not jetton one!
17- const string receiverWalletWallet = "EQC403uCzev_-2g8fNfFPOgr5xOxCoTrCX2gp6OMK6YDtARk" ;
22+ const string receiverWalletWalletTestnet = "EQC403uCzev_-2g8fNfFPOgr5xOxCoTrCX2gp6OMK6YDtARk" ;
1823
1924 private readonly ITonClient tonClient ;
2025 private readonly ILogger logger ;
@@ -27,30 +32,40 @@ public Jettons(ITonClient tonClient, ILogger<Jettons> logger)
2732
2833 public async Task Run ( bool inMainnet )
2934 {
30- if ( inMainnet )
31- {
32- logger . LogWarning ( "Jettons() sample in Mainnet is disabled for safety reasons. Switch to testnet in Program.cs and try again." ) ;
33- return ;
34- }
35+ var jettonMinterAddress = inMainnet ? jettonMinterAddressMainnet : jettonMinterAddressTestnet ;
36+ var ownerWalletAddress = inMainnet ? ownerWalletAddressMainnet : ownerWalletAddressTestnet ;
3537
3638 await tonClient . InitIfNeeded ( ) ;
3739
38- var ownerJettonAddress = await TonRecipes . Jettons . GetWalletAddress ( tonClient , jettonMasterAddress , ownerWalletAddress ) ;
40+ var ownerJettonAddress = await TonRecipes . Jettons . GetWalletAddress ( tonClient , jettonMinterAddress , ownerWalletAddress ) ;
3941 logger . LogInformation ( "Jetton address for owner wallet {Wallet} is: {Address}" , ownerWalletAddress , ownerJettonAddress ) ;
4042
41- var ( bal , own , mst ) = await TonRecipes . Jettons . GetJettonAddressInfo ( tonClient , ownerJettonAddress ) ;
43+ var wd = await TonRecipes . Jettons . GetWalletData ( tonClient , ownerJettonAddress ) ;
4244 logger . LogInformation ( "Info for Jetton address {Address}:" , ownerJettonAddress ) ;
43- logger . LogInformation ( " Balance: {Value}" , bal ) ;
44- logger . LogInformation ( " Owner: {Value}" , own ) ;
45- logger . LogInformation ( " Jett.Master: {Value}" , mst ) ;
45+ logger . LogInformation ( " Balance: {Value}" , wd . balance ) ;
46+ logger . LogInformation ( " Owner: {Value}" , wd . ownerAddress ) ;
47+ logger . LogInformation ( " Jett.Master: {Value}" , wd . jettonMinterAddress ) ;
48+ logger . LogInformation ( " Code: \r \n {Value}" , wd . jettonWalletCode . DumpCells ( ) ) ;
49+
50+ var jd = await TonRecipes . Jettons . GetJettonData ( tonClient , jettonMinterAddress ) ;
51+ logger . LogInformation ( "Info for Jetton Minter address {Address}:" , jettonMinterAddress ) ;
52+ logger . LogInformation ( " Total supply:{Value}" , jd . totalSupply ) ;
53+ logger . LogInformation ( " Mintable: {Value}" , jd . mintable ) ;
54+ logger . LogInformation ( " Admin: {Value}" , jd . adminAddress ) ;
55+ logger . LogInformation ( " Content: \r \n {Value}" , jd . jettonContent . DumpCells ( ) ) ;
56+ logger . LogInformation ( " Wallet code: \r \n {Value}" , jd . jettonWalletCode . DumpCells ( ) ) ;
4657
47- if ( string . IsNullOrWhiteSpace ( Program . TestMnemonic ) )
58+ if ( inMainnet )
59+ {
60+ logger . LogWarning ( "Jettons transfer sample in Mainnet is disabled for safety reasons. Switch to testnet in Program.cs and try again." ) ;
61+ }
62+ else if ( string . IsNullOrWhiteSpace ( Program . TestMnemonic ) )
4863 {
4964 logger . LogWarning ( "Actual mnemonic is not set, sending jettons code is skipped. Put mnemonic phrase in Prograg.cs and try again." ) ;
5065 }
5166 else
5267 {
53- var msg = TonRecipes . Jettons . CreateTransferMessage ( ownerJettonAddress , 12345 , 1_000_000_000 , receiverWalletWallet , ownerWalletAddress , null , 0.01M , null ) ;
68+ var msg = TonRecipes . Jettons . CreateTransferMessage ( ownerJettonAddress , 12345 , 1_000_000_000 , receiverWalletWalletTestnet , ownerWalletAddress , null , 0.01M , null ) ;
5469
5570 var inputKey = await tonClient . ImportKey ( new ExportedKey ( Program . TestMnemonic . Split ( ' ' ) . ToList ( ) ) ) ;
5671
0 commit comments