-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfreetonso.cmd
462 lines (379 loc) · 10.7 KB
/
freetonso.cmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
@setlocal enableextensions enabledelayedexpansion
@echo off
Title Free TON Simple Operations
REM
REM Just a simple script file for SubGovs and other who find it helpful
REM Made in Cyberspace, 2020, December by Axel Foly - @axelfoly in Freeton.one
REM
echo Loading...
set walletFile=addr.ini
set depoolFile=depool.ini
set signmethodFile=signmethod.ini
color 3
:MENU
if exist %walletFile% (
set /P ADDR=<%walletFile%
if "!ADDR!"=="" (
set ADDR_DESKTOP=
) else (
set ADDR_DESKTOP=^(!ADDR:~0,13!...!ADDR:~-13!^)
)
)
if exist %depoolFile% (
set /P DEPOOL=<%depoolFile%
if "!DEPOOL!"=="" (
set DEPOOL_DESKTOP=
) else (
set DEPOOL_DESKTOP=^(!DEPOOL:~0,13!...!DEPOOL:~-13!^)
)
)
if exist %signmethodFile% (
set /P SIGN_METHOD=<%signmethodFile%
) else (
set SIGN_METHOD=seedphrase
)
if "%SIGN_METHOD%"=="" set SIGN_METHOD=seedphrase
tonos-cli --version 2>nul | find "tonos_cli">tonos-cli-version.tmp
for /f %%i in ("tonos-cli-version.tmp") do set size=%%~zi
if %size% gtr 0 (
for /f "tokens=2" %%G in (tonos-cli-version.tmp) do SET TONOSCLI_VERSION=%%G
set TONOSCLI_VERSION=!TONOSCLI_VERSION:"=!
set TONOSCLI_VERSION=!TONOSCLI_VERSION:,=!
del tonos-cli-version.tmp
) else (
set TONOSCLI_VERSION="n/a"
)
cls
echo *------------------------------------------------------*
echo * Free TON Simple Operations (tonos-cli !TONOSCLI_VERSION!) *
echo *------------------------------------------------------*
echo 1 - My wallet address %ADDR_DESKTOP%
echo 2 - Generate msig.keys.json file
echo 3 - Change the sign method (%SIGN_METHOD%)
echo 4 - Show wallet balance and stakes
echo 5 - Send tokens
echo 6 - Get transactions to sign
echo 7 - Sign the transaction
echo 8 - Stake to DePool
echo 9 - Withdraw entire Stake from DePool
echo 10 - Withdraw part of the Stake from DePool
echo 11 - Remove Stake from DePool
echo 12 - Cancel all withdrawals
echo 13 - DePool address %DEPOOL_DESKTOP%
echo *------------------------------------------------------*
set /P CHOICE=Type your option and press enter or 'q' to exit:
if %CHOICE%==q exit
if %CHOICE%==1 goto MY_WALLET
if %CHOICE%==2 goto GENERATE_KEYS_FILE
if %CHOICE%==3 goto SIGN_METHOD
if %CHOICE%==4 goto GET_ACCOUNT
if %CHOICE%==5 goto SEND_TOKENS
if %CHOICE%==6 goto GET_TRANSACTIONS
if %CHOICE%==7 goto SIGN_TRANSACTION
if %CHOICE%==8 goto STAKE_TO_DEPOOL
if %CHOICE%==9 goto WITHDRAW_STAKE_ENTIRE
if %CHOICE%==10 goto WITHDRAW_STAKE_PART
if %CHOICE%==11 goto REMOVE_STAKE
if %CHOICE%==12 goto WITHDRAW_CANCEL
if %CHOICE%==13 goto DEPOOL_SETTINGS
goto :MENU
:MY_WALLET
cls
echo.
echo Your current addr in %walletFile%: %ADDR%
set /P NEWADDR=Enter the new wallet address:
if "%NEWADDR%"=="" (
goto MENU
) else (
echo Saving to %walletFile%...
echo %NEWADDR%>%walletFile%
echo Wallet address has been saved into %walletFile%
)
pause
goto MENU
:DEPOOL_SETTINGS
cls
echo.
echo Current DePool addr in %walletFile%: %DEPOOL%
set /P NEWDEPOOL=Enter new DePool address:
if "%NEWDEPOOL%"=="" (
goto MENU
) else (
echo Saving to %depoolFile%...
echo %NEWDEPOOL%>%depoolFile%
echo New DePool address has been saved into %depoolFile%
)
pause
goto MENU
:GET_ACCOUNT
CLS
if not defined ADDR (
goto :MY_WALLET
)
tonos-cli account %ADDR% | find "balance">account_balance.tmp
for /f "tokens=2" %%G in (account_balance.tmp) do SET BALANCE=%%G
for /f %%i in ("account_balance.tmp") do set size=%%~zi
if %size% gtr 0 (
set BALANCE=!BALANCE:"=!
set BALANCE=!BALANCE:,=!
for /f %%# in ('nano2ton.cmd !BALANCE!') do set "BALANCE=%%#"
) else (
set BALANCE=Not found
)
del account_balance.tmp
echo.
echo Addr: %ADDR%
echo Balance: !BALANCE!
if defined DEPOOL (
goto :GET_DEPOOL_PARTICIPANT_INFO
) else (
goto :GET_DEPOOL_PARTICIPANT_INFO_END
)
:GET_DEPOOL_PARTICIPANT_INFO
echo.
tonos-cli run %DEPOOL% getParticipantInfo "{\"addr\":\"%ADDR%\"}" --abi DePoolv3.abi.json 2>nul | find "total">account_stakes.tmp
tonos-cli run %DEPOOL% getParticipantInfo "{\"addr\":\"%ADDR%\"}" --abi DePoolv3.abi.json 2>nul | find "reward">account_rewards.tmp
for /f %%i in ("account_stakes.tmp") do set size=%%~zi
if %size% equ 0 (
del account_stakes.tmp
del account_rewards.tmp
tonos-cli run %DEPOOL% getParticipantInfo "{\"addr\":\"%ADDR%\"}" --abi DePoolv2.abi.json 2>nul | find "total">account_stakes.tmp
tonos-cli run %DEPOOL% getParticipantInfo "{\"addr\":\"%ADDR%\"}" --abi DePoolv2.abi.json 2>nul | find "reward">account_rewards.tmp
)
for /f %%i in ("account_stakes.tmp") do set size=%%~zi
if %size% gtr 0 (
for /f "tokens=2" %%G in (account_stakes.tmp) do SET STAKE=%%G
set STAKE=!STAKE:"=!
set STAKE=!STAKE:,=!
for /f %%# in ('nano2ton.cmd !STAKE!') do set "STAKE=%%#"
for /f %%i in ("account_rewards.tmp") do set size=%%~zi
if %size% gtr 0 (
for /f "tokens=2" %%G in (account_rewards.tmp) do SET REWARDS=%%G
set REWARDS=!REWARDS:"=!
set REWARDS=!REWARDS:,=!
for /f %%# in ('nano2ton.cmd !REWARDS!') do set "REWARDS=%%#"
) else (
set REWARDS=0)
) else (
set STAKE=0
)
echo DePool: %DEPOOL%
echo Stake: !STAKE!
echo Rewards: !REWARDS!
del account_stakes.tmp
del account_rewards.tmp
:GET_DEPOOL_PARTICIPANT_INFO_END
echo.
pause
goto MENU
:SEND_TOKENS
set DEST=
set VALUE=
set SEED=
cls
if not defined ADDR (
goto :MY_WALLET
)
echo.
set /P DEST=Enter destination address:
if "!DEST!"=="" (goto :SEND_TOKENS)
:SEND_TOKENS_VALUE
set /P VALUE=Enter value in tokens (TON Crystals):
if "!VALUE!"=="" (goto :SEND_TOKENS_VALUE)
set VALUE=%VALUE%000000000
if "%SIGN_METHOD%"=="seedphrase" (
echo.
:SEND_TOKENS_SEED
set /P SEED=Enter the seed phrase:
if "!SEED!"=="" (goto :SEND_TOKENS_SEED)
echo.
set SIGNATURE="!SEED!"
) else (
set SIGNATURE=!SIGN_METHOD!
)
echo.
echo Choose your wallet's contract:
:SEND_TOKENS_MENU_ABI
echo 1 - SetcodeMultisigWallet (Surf)
echo 2 - SafeMultisigWallet (Multisig "classic")
echo.
set /P CHOICE=Type your option and press enter or 'q' to MENU:
if %CHOICE%==1 set CONTRACT_ABI=SetcodeMultisigWallet.abi.json
if %CHOICE%==2 set CONTRACT_ABI=SafeMultisigWallet.abi.json
if %CHOICE%==q goto :MENU
if "!CONTRACT_ABI!"=="" (goto :SEND_TOKENS_MENU_ABI)
echo.
echo Contract: !CONTRACT_ABI!
echo Sign method: %SIGN_METHOD%
echo Destination: !DEST!
echo Value: !VALUE!
pause
echo Processing...
tonos-cli call %ADDR% submitTransaction "{\"dest\":\"%DEST%\",\"value\":%VALUE%,\"bounce\":true,\"allBalance\":false,\"payload\":\"\"}" --abi %CONTRACT_ABI% --sign %SIGNATURE%
pause
set DEST=
set VALUE=
set SEED=
goto MENU
:GENERATE_KEYS_FILE
echo Let's generate msig.keys.json file
echo.
:GENERATE_KEYS_FILE_SEED
set /P SEED=Enter your seed phrase:
if "!SEED!"=="" (goto :GENERATE_KEYS_FILE_SEED)
echo Processing...
tonos-cli getkeypair msig.keys.json "%SEED%"
echo Your keys placed to the msig.keys.json file
pause
goto SIGN_METHOD_MENU
:SIGN_METHOD
color 2
:SIGN_METHOD_MENU
cls
echo Choose the method to sign transaction:
echo.
echo s - Using a seed phrase
echo m - Using msig.keys.json file
echo.
set /P CHOICE=Select your option and press enter:
if %CHOICE%==s set SIGN_METHOD_NEW=seedphrase
if %CHOICE%==m set SIGN_METHOD_NEW=msig.keys.json
if "!SIGN_METHOD_NEW!"=="" (goto :SIGN_METHOD)
if %SIGN_METHOD_NEW%==msig.keys.json (
if not exist msig.keys.json (
echo File msig.keys.json not found
goto :GENERATE_KEYS_FILE
)
)
echo !SIGN_METHOD_NEW!>%signmethodFile%
Color 3
goto MENU
:GET_TRANSACTIONS
echo Processing...
if not defined ADDR (
goto :MY_WALLET
)
tonos-cli run %ADDR% getTransactions {} --abi SafeMultisigWallet.abi.json
pause
goto MENU
:SIGN_TRANSACTION
if not defined ADDR (
goto :MY_WALLET
)
set /P TRANSACTION=Enter transaction ID:
if "%SIGN_METHOD%"=="seedphrase" (
echo.
set /P SEED=Enter the seed phrase:
echo.
set SIGNATURE="!SEED!"
) else (
set SIGNATURE=!SIGN_METHOD!
)
echo Transaction: !TRANSACTION!
echo Sign method: %SIGN_METHOD%
pause
echo "Processing..."
tonos-cli call %ADDR% confirmTransaction "{\"transactionId\":\"%TRANSACTION%\"}" --abi SafeMultisigWallet.abi.json --sign %SIGNATURE%
set SEED=
pause
goto MENU
:STAKE_TO_DEPOOL
if not defined ADDR (
goto :MY_WALLET
)
if not defined DEPOOL (
goto :DEPOOL_SETTINGS
)
echo DePool: %DEPOOL%
echo Wallet: %ADDR%
set /P VALUE=Enter value in tokens:
echo Value: !VALUE!
if "%SIGN_METHOD%"=="seedphrase" (
echo.
:STAKE_TO_DEPOOL_ENTER_SEED
set /P SEED=Enter the seed phrase:
if "!SEED!"=="" (goto STAKE_TO_DEPOOL_ENTER_SEED)
echo.
set SIGNATURE="!SEED!"
) else (
set SIGNATURE=!SIGN_METHOD!
)
echo Sign method: %SIGN_METHOD%
pause
echo "Processing..."
tonos-cli depool --addr %DEPOOL% stake ordinary --wallet %ADDR% --value %VALUE% --sign %SIGNATURE%
echo "You can check your stakes by select #4 in main menu"
pause
goto MENU
:REMOVE_STAKE
echo DePool: %DEPOOL%
echo Wallet: %ADDR%
set /P VALUE=Enter value in tokens:
echo Remove value: !VALUE!
if "%SIGN_METHOD%"=="seedphrase" (
echo.
set /P SEED=Enter the seed phrase:
echo.
set SIGNATURE="!SEED!"
) else (
set SIGNATURE=!SIGN_METHOD!
)
echo Sign method: %SIGN_METHOD%
pause
echo "Processing..."
tonos-cli depool --addr %DEPOOL% stake remove --wallet %ADDR% --value %VALUE% --sign %SIGNATURE%
pause
goto MENU
:WITHDRAW_STAKE_ENTIRE
echo DePool: %DEPOOL%
echo Wallet: %ADDR%
if "%SIGN_METHOD%"=="seedphrase" (
echo.
set /P SEED=Enter the seed phrase:
echo.
set SIGNATURE="!SEED!"
) else (
set SIGNATURE=!SIGN_METHOD!
)
echo Sign method: %SIGN_METHOD%
pause
echo "Processing..."
tonos-cli depool --addr %DEPOOL% withdraw on --wallet %ADDR% --sign %SIGNATURE%
pause
goto MENU
:WITHDRAW_STAKE_PART
echo DePool: %DEPOOL%
echo Wallet: %ADDR%
set /P VALUE=Enter value in tokens:
echo Withdraw value: !VALUE!
if "%SIGN_METHOD%"=="seedphrase" (
echo.
set /P SEED=Enter the seed phrase:
echo.
set SIGNATURE="!SEED!"
) else (
set SIGNATURE=!SIGN_METHOD!
)
echo Sign method: %SIGN_METHOD%
pause
echo "Processing..."
tonos-cli depool --addr %DEPOOL% stake withdrawPart --wallet %ADDR% --value %VALUE% --sign %SIGNATURE%
pause
goto MENU
:WITHDRAW_CANCEL
echo DePool: %DEPOOL%
echo Wallet: %ADDR%
if "%SIGN_METHOD%"=="seedphrase" (
echo.
set /P SEED=Enter the seed phrase:
echo.
set SIGNATURE="!SEED!"
) else (
set SIGNATURE=!SIGN_METHOD!
)
echo Sign method: %SIGN_METHOD%
pause
echo "Processing..."
tonos-cli depool --addr %DEPOOL% withdraw off --wallet %ADDR% --sign %SIGNATURE%
pause
goto MENU