Skip to content

Instantly share code, notes, and snippets.

@helderjnpinto
Last active May 25, 2023 18:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save helderjnpinto/2416f4d5e3f0dc3349ee07d976e15536 to your computer and use it in GitHub Desktop.
Save helderjnpinto/2416f4d5e3f0dc3349ee07d976e15536 to your computer and use it in GitHub Desktop.
#pragma version 8
if Txn.ApplicationID == 0:
# Handle Create App
exit(1)
end
switch Txn.OnCompletion:
NoOp: main
OptIn: opt_in
CloseOut: close_out
UpdateApplication: update_app
DeleteApplication: delete_app
end
block opt_in:
# Handle Opt In
# some statements here
# exit(1)
# OR
# Disallow Opt In
exit(0)
end
block close_out:
# Handle Close Out
# some statements here
# exit(1)
# OR
# Disallow Closing Out
exit(0)
end
block update_app:
# Handle Update App
# Example: Only allow the Creator to update the app (useful during development)
exit(Txn.Sender == Global.CreatorAddress)
# OR
# Disallow Update App
# exit(0)
end
block delete_app:
# Handle Delete App
# Example: Only allow the Creator to update the app (useful during development)
exit(Txn.Sender == Global.CreatorAddress)
# OR
# Disallow Delete App
# exit(0)
end
block main:
switch Txn.ApplicationArgs[0]:
"method_a": method_a
end
block method_a:
exit(1)
end
end
func calc(from_round: int) int:
int end_round = Global.Round
if end_round > 10:
end_round = 10
end
return end_round - from_round
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment