6
{ show-options-help 1 halt } : usage
8
Basechain =: wc // create smart contract in basechain
10
"new-dns-query.boc" =: savefile
11
variable dns-dict dictnew dns-dict !
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
31
$2 parse-int dup =: contract-id
33
{ contract-id (.) $+ } : +contractid
35
."Creating new manual DNS smart contract in workchain " wc .
36
."with contract id " contract-id . cr
38
// Create new manual DNS; source code included from `auto/dns-manual-code.fif`
39
"auto/dns-manual-code.fif" include
41
<b contract-id 32 i, 0 64 u,
42
file-base +".pk" load-generate-keypair
44
B, dns-dict @ dict, false 1 i,
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
63
."(Saved dns smart-contract creating query to file " type .")" cr