"TonUtil.fif" include "lib.fif" include { ."usage: " @' $0 type ." [ ... ]" cr ."Runs the function with ID in the TON VM, using code and storage data from .boc and .boc as message (OR as the only integer parameter of get-method, if .boc does not exist)." cr 1 halt } : usage $# 3 < ' usage if $1 +".boc" load-boc const init-boc $# 1- 2 /c const message-count variable-set function function! variable-set code code! variable-set storage storage! variable-set retcode retcode! // c7 // [ magic:0x076ef1ea actions:Integer msgs_sent:Integer // unixtime:Integer block_lt:Integer trans_lt:Integer // rand_seed:Integer balance_remaining:[Integer (Maybe Cell)] // myself:MsgAddressInt global_config:(Maybe Cell) // ] = SmartContractInfo; 0x076ef1ea 0 0 now 0 0 hash 7 tuple 1 tuple const ctx // message$_ {X:Type} info:CommonMsgInfo // init:(Maybe (Either StateInit ^StateInit)) // body:(Either X ^X) = Message X; init-boc { ."There seems to be an invalid header" cr } if // 1000100 => 68 8 i@+ 256 u@+ -rot ."Init wallet address: " .addr cr Gram@+ nip // Ignore grams 1 u@+ swap 1- abort"This does not seem to be an init message" 1 u@+ swap { ."Loading ref..." cr ref@ abort"Exception" } : ponyvm cr ."===================================================" cr cr ponyvm 2 { dup 1+ swap // Increase counter cr ."===================================================" cr cr $() +".boc" dup file-exists? { load-boc inspect // Automatically sets message-contents } { drop dup 1- $() parse-int // message-contents! } cond dup 1+ swap // Increase counter $() parse-int function! ponyvm // Manually drop return values of functions function -1 <> { 2drop } if // rot // ."Signature: " // 64 B@ Bx. } message-count times