Skip to content

Instantly share code, notes, and snippets.

@Rexagon
Last active May 24, 2024 13:04
Show Gist options
  • Save Rexagon/bb78a0b7686ea0be3e878bc0fca83fb2 to your computer and use it in GitHub Desktop.
Save Rexagon/bb78a0b7686ea0be3e878bc0fca83fb2 to your computer and use it in GitHub Desktop.
Generates a simple hello-world contract
"TonUtil.fif" include
"Asm.fif" include
"Lists.fif" include
"GetOpt.fif" include
{ show-options-help 1 halt } : usage
false =: tick
false =: tock
variable extra-currencies
{ extra-currencies @ cc+ extra-currencies ! } : extra-cc+!
begin-options
" <balance> [-x <extra-balance>*<extra-currency-id>] [--tick] [--tock]" +cr +cr
+"Creates a state for a tick-tock account" +cr
disable-digit-options generic-help-setopt
"--tick" { true =: tick } long-option
"Enables tick trigger" option-help
"--tock" { true =: tock } long-option
"Enables tock trigger" option-help
"x" "--extra" { $>xcc extra-cc+! } short-long-option-arg
"Indicates the balance in extra currencies" option-help
"h" "--help" { usage } short-long-option
"Shows a help message" option-help
parse-options
$# 1 < ' usage if
$1 $>cc extra-cc+! extra-currencies @ 2=: balance
<b b{110000} s, 0 64 u, 0 32 u, 0 2 u, 0 32 u, "Hello, world!" $, b> constant ext_msg
PROGRAM{
recv_internal x{} PROC
run_ticktock PROC:<{
ext_msg PUSHREF ZERO SENDRAWMSG
}>
}END>c constant code
<b b{01} s, tick 1 u, tock 1 u, b{100} s, code ref, b> constant state_init
// b account - b
{ swap b{100} s, -1 8 i, swap 256 u, } : addr_std,
// b state_init - b
{ swap 0 64 u, balance Gram+cc, b{1} s, swap <s s, } : account_storage,
// b - b
{ b{000000000} s, 0 32 u, b{0} s, } : storage_info,
<b b{1} s,
state_init hashu addr_std,
storage_info,
state_init account_storage,
b> boc>base64 type cr
@Rexagon
Copy link
Author

Rexagon commented May 24, 2024

fift -s ./gen_ticktock.fif 1000 --tick --tock

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment