Skip to content

Instantly share code, notes, and snippets.

@manishrjain
Created July 27, 2023 23:01
Show Gist options
  • Save manishrjain/1a4083e42a2368efa1aef1dc384c80ec to your computer and use it in GitHub Desktop.
Save manishrjain/1a4083e42a2368efa1aef1dc384c80ec to your computer and use it in GitHub Desktop.

Revisions

  1. manishrjain created this gist Jul 27, 2023.
    25 changes: 25 additions & 0 deletions test-code.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@

    Let's test this thing:

    ```
    python
    from pyteal import *
    def smart_contract():
    on_creation = Seq([
    App.globalPut(Bytes("required_arg"), Txn.application_args[0]),
    App.globalPut(Bytes("optional_arg"), If(Txn.application_args.length() > Int(1), Txn.application_args[1], Bytes("default_value"))),
    Int(1)
    ])
    program = Cond(
    [Txn.application_id() == Int(0), on_creation]
    )
    return program
    if __name__ == "__main__":
    with open("smart_contract.teal", "w") as f:
    compiled = compileTeal(smart_contract(), mode=Mode.Application, version=4)
    f.write(compiled)
    ```