#!/usr/bin/fift -s "TonUtil.fif" include "Asm.fif" include { ."usage: " @' $0 type ." []" cr ."Creates a new money giver in specified workchain, with address saved to .addr" cr ."('new-testgiver.addr' by default)" cr 1 halt } : usage $# 1- -2 and ' usage if $1 parse-workchain-id =: wc // set workchain id from command line argument def? $2 { @' $2 } { "new-testgiver" } cond constant file-base ."Creating new money giver in workchain " wc . cr 0 constant init_seqno // Create new simple money giver <{ SETCP0 DUP IFNOTRET // return if recv_internal DUP 85143 INT EQUAL IFJMP:<{ // "seqno" get-method DROP c4 PUSHCTR CTOS 32 PLDU // cnt }> INC 32 THROWIF // fail unless recv_external 32 LDU SWAP // cs cnt c4 PUSHCTR CTOS 32 LDU ENDS // cs cnt cnt' TUCK EQUAL 33 THROWIFNOT // ( seqno mismatch? ) ACCEPT // cs cnt' SWAP DUP SREFS // cnt' cs msg? IF:<{ 8 LDU LDREF -ROT // cnt'' cs mode msg GR$20 INT 3 INT RAWRESERVE // reserve all but 20 Grams from the balance SWAP SENDRAWMSG }> ENDS INC NEWC 32 STU ENDC c4 POPCTR // store cnt'' }>c // code // data null // no libraries // create StateInit dup ."StateInit: " dup ."External message for initialization is " B dup Bx. cr file-base +"-query.boc" tuck B>file ."(Saved money giver creating query to file " type .")" cr