Ton

Форк
0
/
new-manual-dns.fif 
63 строки · 2.5 Кб
1
#!/usr/bin/fift -s
2
"TonUtil.fif" include
3
"Asm.fif" include
4
"GetOpt.fif" include
5

6
{ show-options-help 1 halt } : usage
7

8
Basechain =: wc   // create smart contract in basechain
9
65536 =: timeout
10
"new-dns-query.boc" =: savefile
11
variable dns-dict  dictnew dns-dict !
12

13
begin-options
14
     " <filename-base> <contract-id> [-w<workchain>] [-t<timeout>] [-o<savefile-boc>]" +cr +tab
15
    +"Creates a new manual dns smart contract with 32-bit identifier <contract-id> managed by private key <filename-base>.pk, "
16
    +"and saves it into <savefile-boc> ('" savefile $+ +"' by default)"
17
    disable-digit-options generic-help-setopt
18
  "w" "--workchain" { parse-workchain-id =: wc } short-long-option-arg
19
    "Selects workchain to create smart contract (" wc (.) $+ +" by default)" option-help
20
  "t" "--timeout" { parse-int =: timeout } short-long-option-arg
21
    "Sets expiration timeout for the initialization message in seconds (" timeout (.) $+ +" by default)" option-help
22
  "o" "--output" { =: savefile } short-long-option-arg
23
    "Sets output file for generated initialization message ('" savefile $+ +"' by default)" option-help
24
  "h" "--help" { usage } short-long-option
25
    "Shows a help message" option-help
26
parse-options
27

28
$# 2 <> ' usage if
29
2 :$1..n
30
$1 =: file-base
31
$2 parse-int dup =: contract-id
32
32 fits ' usage ifnot
33
{ contract-id (.) $+ } : +contractid
34

35
."Creating new manual DNS smart contract in workchain " wc .
36
."with contract id " contract-id . cr
37

38
// Create new manual DNS; source code included from `auto/dns-manual-code.fif`
39
"auto/dns-manual-code.fif" include
40
// code
41
<b contract-id 32 i, 0 64 u,
42
   file-base +".pk" load-generate-keypair
43
   constant wallet_pk
44
   B, dns-dict @ dict, false 1 i,
45
b> // data
46
null // no libraries
47
<b b{0011} s, 3 roll ref, rot ref, swap dict, b>  // create StateInit
48
dup ."StateInit: " <s csr. cr
49
dup hashu wc swap 2dup 2constant wallet_addr
50
."new manual DNS smartcontract address = " 2dup .addr cr
51
2dup file-base +"-dns" +contractid +".addr" save-address-verbose
52
."Non-bounceable address (for init): " 2dup 7 .Addr cr
53
."Bounceable address (for later access): " 6 .Addr cr
54
now timeout + 32 << 1- dup =: query_id
55
."Init query_id is " dup . ."(0x" X._ .")" cr
56
<b contract-id 32 i, query_id 64 u, 0 6 u, b>
57
dup ."signing message: " <s csr. cr
58
dup hashu wallet_pk ed25519_sign_uint rot
59
<b b{1000100} s, wallet_addr addr, b{000010} s, swap <s s, b{0} s, swap B, swap <s s, b>
60
dup ."External message for initialization is " <s csr. cr
61
2 boc+>B dup Bx. cr
62
savefile tuck B>file
63
."(Saved dns smart-contract creating query to file " type .")" cr
64

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.