From 7cb13393c1fccf59b9e298e6481d3ea0be79991a Mon Sep 17 00:00:00 2001 From: Daniel McGregor Date: Mon, 11 Dec 2023 16:06:14 +0800 Subject: [PATCH] doc: add hello world examples --- examples/hello_world/arc4_contract.py | 8 + examples/hello_world/contract.py | 11 + examples/hello_world/out/application.json | 54 ++++ .../out/arc4_contract.approval.debug.teal | 60 +++++ .../out/arc4_contract.approval.teal | 56 +++++ ...4_contract.approval_unoptimized.debug.teal | 69 ++++++ .../arc4_contract.approval_unoptimized.teal | 65 +++++ examples/hello_world/out/arc4_contract.awst | 7 + .../out/arc4_contract.clear.debug.teal | 9 + .../hello_world/out/arc4_contract.clear.teal | 7 + ...arc4_contract.clear_unoptimized.debug.teal | 9 + .../out/arc4_contract.clear_unoptimized.teal | 7 + .../arc4_contract_HelloWorldContract.cssa.ir | 42 ++++ .../arc4_contract_HelloWorldContract.final.ir | 42 ++++ ...ct_HelloWorldContract.final_unoptimized.ir | 46 ++++ ...ract_HelloWorldContract.parallel_copies.ir | 42 ++++ ...c4_contract_HelloWorldContract.post_ssa.ir | 42 ++++ .../arc4_contract_HelloWorldContract.ssa.ir | 46 ++++ ...tract_HelloWorldContract.ssa.opt_pass_1.ir | 42 ++++ ...tract_HelloWorldContract.ssa.opt_pass_2.ir | 42 ++++ .../out/contract.approval.debug.teal | 14 ++ .../hello_world/out/contract.approval.teal | 12 + .../contract.approval_unoptimized.debug.teal | 14 ++ .../out/contract.approval_unoptimized.teal | 12 + examples/hello_world/out/contract.awst | 14 ++ .../hello_world/out/contract.clear.debug.teal | 9 + examples/hello_world/out/contract.clear.teal | 7 + .../out/contract.clear_unoptimized.debug.teal | 9 + .../out/contract.clear_unoptimized.teal | 7 + .../out/contract_HelloWorldContract.cssa.ir | 13 + .../out/contract_HelloWorldContract.final.ir | 13 + ...ct_HelloWorldContract.final_unoptimized.ir | 13 + ...ract_HelloWorldContract.parallel_copies.ir | 13 + .../contract_HelloWorldContract.post_ssa.ir | 13 + .../out/contract_HelloWorldContract.ssa.ir | 13 + examples/hello_world/puya.log | 233 ++++++++++++++++++ examples/sizes.txt | 2 + 37 files changed, 1117 insertions(+) create mode 100644 examples/hello_world/arc4_contract.py create mode 100644 examples/hello_world/contract.py create mode 100644 examples/hello_world/out/application.json create mode 100644 examples/hello_world/out/arc4_contract.approval.debug.teal create mode 100644 examples/hello_world/out/arc4_contract.approval.teal create mode 100644 examples/hello_world/out/arc4_contract.approval_unoptimized.debug.teal create mode 100644 examples/hello_world/out/arc4_contract.approval_unoptimized.teal create mode 100644 examples/hello_world/out/arc4_contract.awst create mode 100644 examples/hello_world/out/arc4_contract.clear.debug.teal create mode 100644 examples/hello_world/out/arc4_contract.clear.teal create mode 100644 examples/hello_world/out/arc4_contract.clear_unoptimized.debug.teal create mode 100644 examples/hello_world/out/arc4_contract.clear_unoptimized.teal create mode 100644 examples/hello_world/out/arc4_contract_HelloWorldContract.cssa.ir create mode 100644 examples/hello_world/out/arc4_contract_HelloWorldContract.final.ir create mode 100644 examples/hello_world/out/arc4_contract_HelloWorldContract.final_unoptimized.ir create mode 100644 examples/hello_world/out/arc4_contract_HelloWorldContract.parallel_copies.ir create mode 100644 examples/hello_world/out/arc4_contract_HelloWorldContract.post_ssa.ir create mode 100644 examples/hello_world/out/arc4_contract_HelloWorldContract.ssa.ir create mode 100644 examples/hello_world/out/arc4_contract_HelloWorldContract.ssa.opt_pass_1.ir create mode 100644 examples/hello_world/out/arc4_contract_HelloWorldContract.ssa.opt_pass_2.ir create mode 100644 examples/hello_world/out/contract.approval.debug.teal create mode 100644 examples/hello_world/out/contract.approval.teal create mode 100644 examples/hello_world/out/contract.approval_unoptimized.debug.teal create mode 100644 examples/hello_world/out/contract.approval_unoptimized.teal create mode 100644 examples/hello_world/out/contract.awst create mode 100644 examples/hello_world/out/contract.clear.debug.teal create mode 100644 examples/hello_world/out/contract.clear.teal create mode 100644 examples/hello_world/out/contract.clear_unoptimized.debug.teal create mode 100644 examples/hello_world/out/contract.clear_unoptimized.teal create mode 100644 examples/hello_world/out/contract_HelloWorldContract.cssa.ir create mode 100644 examples/hello_world/out/contract_HelloWorldContract.final.ir create mode 100644 examples/hello_world/out/contract_HelloWorldContract.final_unoptimized.ir create mode 100644 examples/hello_world/out/contract_HelloWorldContract.parallel_copies.ir create mode 100644 examples/hello_world/out/contract_HelloWorldContract.post_ssa.ir create mode 100644 examples/hello_world/out/contract_HelloWorldContract.ssa.ir create mode 100644 examples/hello_world/puya.log diff --git a/examples/hello_world/arc4_contract.py b/examples/hello_world/arc4_contract.py new file mode 100644 index 0000000000..8d9dab2094 --- /dev/null +++ b/examples/hello_world/arc4_contract.py @@ -0,0 +1,8 @@ +from puyapy import ARC4Contract, Bytes, log +from puyapy.arc4 import String, abimethod + + +class HelloWorldContract(ARC4Contract): + @abimethod + def say_hello(self, name: String) -> None: + log(Bytes(b"Hello ") + name.decode()) diff --git a/examples/hello_world/contract.py b/examples/hello_world/contract.py new file mode 100644 index 0000000000..15f75924ec --- /dev/null +++ b/examples/hello_world/contract.py @@ -0,0 +1,11 @@ +from puyapy import Bytes, Contract, Transaction, log + + +class HelloWorldContract(Contract): + def approval_program(self) -> bool: + name = Transaction.application_args(0) + log(Bytes(b"Hello ") + name) + return True + + def clear_state_program(self) -> bool: + return True diff --git a/examples/hello_world/out/application.json b/examples/hello_world/out/application.json new file mode 100644 index 0000000000..ce537056e6 --- /dev/null +++ b/examples/hello_world/out/application.json @@ -0,0 +1,54 @@ +{ + "hints": { + "say_hello(string)void": { + "call_config": { + "no_op": "CALL" + } + } + }, + "source": { + "approval": "I3ByYWdtYSB2ZXJzaW9uIDgKCi8vIGV4YW1wbGVzLmhlbGxvX3dvcmxkLmFyYzRfY29udHJhY3QuSGVsbG9Xb3JsZENvbnRyYWN0LmFwcHJvdmFsX3Byb2dyYW0oKSAtPiB1aW50NjQ6Cm1haW5fYmxvY2tAMDoKICAgICAgICB0eG4gTnVtQXBwQXJncwogICAgICAgIGJ6IG1haW5fYmFyZV9yb3V0aW5nQDUKCm1haW5fYWJpX3JvdXRpbmdAMToKICAgICAgICB0eG5hIEFwcGxpY2F0aW9uQXJncyAwCiAgICAgICAgbWV0aG9kICJzYXlfaGVsbG8oc3RyaW5nKXZvaWQiCiAgICAgICAgc3dhcAogICAgICAgIG1hdGNoIG1haW5fc2F5X2hlbGxvX3JvdXRlQDIKICAgICAgICBiIG1haW5fc3dpdGNoX2Nhc2VfZGVmYXVsdEAzCgptYWluX3NheV9oZWxsb19yb3V0ZUAyOgogICAgICAgIHR4biBPbkNvbXBsZXRpb24KICAgICAgICAhCiAgICAgICAgYXNzZXJ0IC8vIE9uQ29tcGxldGlvbiBpcyBOb09wCiAgICAgICAgdHhuIEFwcGxpY2F0aW9uSUQKICAgICAgICBhc3NlcnQgLy8gaXMgbm90IGNyZWF0aW5nCiAgICAgICAgdHhuYSBBcHBsaWNhdGlvbkFyZ3MgMQogICAgICAgIGNhbGxzdWIgc2F5X2hlbGxvCiAgICAgICAgaW50IDEKICAgICAgICByZXR1cm4KCm1haW5fc3dpdGNoX2Nhc2VfZGVmYXVsdEAzOgogICAgICAgIGVyciAvLyByZWplY3QgdHJhbnNhY3Rpb24KCm1haW5fYmFyZV9yb3V0aW5nQDU6CiAgICAgICAgdHhuIE9uQ29tcGxldGlvbgogICAgICAgIGJueiBtYWluX3JlamVjdF9iYXJlX29uX2NvbXBsZXRpb25ANwoKbWFpbl9jcmVhdGVANjoKICAgICAgICB0eG4gQXBwbGljYXRpb25JRAogICAgICAgICEKICAgICAgICBhc3NlcnQgLy8gaXMgY3JlYXRpbmcKICAgICAgICBpbnQgMQogICAgICAgIHJldHVybgoKbWFpbl9yZWplY3RfYmFyZV9vbl9jb21wbGV0aW9uQDc6CiAgICAgICAgZXJyIC8vIHJlamVjdCB0cmFuc2FjdGlvbgoKCi8vIGV4YW1wbGVzLmhlbGxvX3dvcmxkLmFyYzRfY29udHJhY3QuSGVsbG9Xb3JsZENvbnRyYWN0LnNheV9oZWxsbyhuYW1lIzA6IGJ5dGVzKSAtPiB2b2lkOgpzYXlfaGVsbG86CiAgICAgICAgcHJvdG8gMSAwCgpzYXlfaGVsbG9fYmxvY2tAMDoKICAgICAgICBmcmFtZV9kaWcgLTEKICAgICAgICBleHRyYWN0IDIgMAogICAgICAgIGJ5dGUgIkhlbGxvICIKICAgICAgICBzd2FwCiAgICAgICAgY29uY2F0CiAgICAgICAgbG9nCiAgICAgICAgcmV0c3ViCgo=", + "clear": "I3ByYWdtYSB2ZXJzaW9uIDgKCi8vIGV4YW1wbGVzLmhlbGxvX3dvcmxkLmFyYzRfY29udHJhY3QuSGVsbG9Xb3JsZENvbnRyYWN0LmNsZWFyX3N0YXRlX3Byb2dyYW0oKSAtPiB1aW50NjQ6Cm1haW5fYmxvY2tAMDoKICAgICAgICBpbnQgMQogICAgICAgIHJldHVybgoK" + }, + "state": { + "global": { + "num_byte_slices": 0, + "num_uints": 0 + }, + "local": { + "num_byte_slices": 0, + "num_uints": 0 + } + }, + "schema": { + "global": { + "declared": {}, + "reserved": {} + }, + "local": { + "declared": {}, + "reserved": {} + } + }, + "contract": { + "name": "HelloWorldContract", + "methods": [ + { + "name": "say_hello", + "args": [ + { + "type": "string", + "name": "name" + } + ], + "returns": { + "type": "void" + } + } + ], + "networks": {} + }, + "bare_call_config": { + "no_op": "CREATE" + } +} \ No newline at end of file diff --git a/examples/hello_world/out/arc4_contract.approval.debug.teal b/examples/hello_world/out/arc4_contract.approval.debug.teal new file mode 100644 index 0000000000..ea83dd5e89 --- /dev/null +++ b/examples/hello_world/out/arc4_contract.approval.debug.teal @@ -0,0 +1,60 @@ +// Op // Op Description Stack (out) Source code Source line + +#pragma version 8 + +// examples.hello_world.arc4_contract.HelloWorldContract.approval_program() -> uint64: +main_block@0: + txn NumAppArgs // {txn} class HelloWorldContract(ARC4Contract): File "hello_world/arc4_contract.py", line 5 + bz main_bare_routing@5 // class HelloWorldContract(ARC4Contract): File "hello_world/arc4_contract.py", line 5 + // Implicit fall through to main_abi_routing@1 // class HelloWorldContract(ARC4Contract): File "hello_world/arc4_contract.py", line 5 + +main_abi_routing@1: + txna ApplicationArgs 0 // {txna} class HelloWorldContract(ARC4Contract): File "hello_world/arc4_contract.py", line 5 + method "say_hello(string)void" // tmp%1#0,method<"say_hello(string)void"> abimethod File "hello_world/arc4_contract.py", line 7 + swap // load tmp%1#0 from l-stack (no copy) method<"say_hello(string)void">,tmp%1#0 class HelloWorldContract(ARC4Contract): File "hello_world/arc4_contract.py", line 5 + match main_say_hello_route@2 // class HelloWorldContract(ARC4Contract): File "hello_world/arc4_contract.py", line 5 + b main_switch_case_default@3 // class HelloWorldContract(ARC4Contract): File "hello_world/arc4_contract.py", line 5 + +main_say_hello_route@2: + txn OnCompletion // {txn} abimethod File "hello_world/arc4_contract.py", line 7 + ! // {!} abimethod File "hello_world/arc4_contract.py", line 7 + assert // OnCompletion is NoOp // abimethod File "hello_world/arc4_contract.py", line 7 + txn ApplicationID // {txn} abimethod File "hello_world/arc4_contract.py", line 7 + assert // is not creating // abimethod File "hello_world/arc4_contract.py", line 7 + txna ApplicationArgs 1 // {txna} class HelloWorldContract(ARC4Contract): File "hello_world/arc4_contract.py", line 5 + callsub say_hello // abimethod File "hello_world/arc4_contract.py", line 7 + int 1 // 1 abimethod File "hello_world/arc4_contract.py", line 7 + return // abimethod File "hello_world/arc4_contract.py", line 7 + +main_switch_case_default@3: + err // reject transaction // class HelloWorldContract(ARC4Contract): File "hello_world/arc4_contract.py", line 5 + +main_bare_routing@5: + txn OnCompletion // {txn} class HelloWorldContract(ARC4Contract): File "hello_world/arc4_contract.py", line 5 + bnz main_reject_bare_on_completion@7 // class HelloWorldContract(ARC4Contract): File "hello_world/arc4_contract.py", line 5 + // Implicit fall through to main_create@6 // class HelloWorldContract(ARC4Contract): File "hello_world/arc4_contract.py", line 5 + +main_create@6: + txn ApplicationID // {txn} class HelloWorldContract(ARC4Contract): File "hello_world/arc4_contract.py", line 5 + ! // {!} class HelloWorldContract(ARC4Contract): File "hello_world/arc4_contract.py", line 5 + assert // is creating // class HelloWorldContract(ARC4Contract): File "hello_world/arc4_contract.py", line 5 + int 1 // 1 class HelloWorldContract(ARC4Contract): File "hello_world/arc4_contract.py", line 5 + return // class HelloWorldContract(ARC4Contract): File "hello_world/arc4_contract.py", line 5 + +main_reject_bare_on_completion@7: + err // reject transaction // class HelloWorldContract(ARC4Contract): File "hello_world/arc4_contract.py", line 5 + + +// examples.hello_world.arc4_contract.HelloWorldContract.say_hello(name#0: bytes) -> void: +say_hello: + proto 1 0 // (𝕡) name#0 | def say_hello(self, name: String) -> None: File "hello_world/arc4_contract.py", line 8 + +say_hello_block@0: + frame_dig -1 // load name#0 from parameters (𝕡) name#0 | name#0 name: String File "hello_world/arc4_contract.py", line 8 + extract 2 0 // (𝕡) name#0 | {extract} name.decode() File "hello_world/arc4_contract.py", line 9 + byte "Hello " // (𝕡) name#0 | tmp%0#0,"Hello " b"Hello " File "hello_world/arc4_contract.py", line 9 + swap // load tmp%0#0 from l-stack (no copy) (𝕡) name#0 | "Hello ",tmp%0#0 name.decode() File "hello_world/arc4_contract.py", line 9 + concat // (𝕡) name#0 | {concat} Bytes(b"Hello ") + name.decode() File "hello_world/arc4_contract.py", line 9 + log // (𝕡) name#0 | log(Bytes(b"Hello ") + name.decode()) File "hello_world/arc4_contract.py", line 9 + retsub // + diff --git a/examples/hello_world/out/arc4_contract.approval.teal b/examples/hello_world/out/arc4_contract.approval.teal new file mode 100644 index 0000000000..2b3cc099cf --- /dev/null +++ b/examples/hello_world/out/arc4_contract.approval.teal @@ -0,0 +1,56 @@ +#pragma version 8 + +// examples.hello_world.arc4_contract.HelloWorldContract.approval_program() -> uint64: +main_block@0: + txn NumAppArgs + bz main_bare_routing@5 + +main_abi_routing@1: + txna ApplicationArgs 0 + method "say_hello(string)void" + swap + match main_say_hello_route@2 + b main_switch_case_default@3 + +main_say_hello_route@2: + txn OnCompletion + ! + assert // OnCompletion is NoOp + txn ApplicationID + assert // is not creating + txna ApplicationArgs 1 + callsub say_hello + int 1 + return + +main_switch_case_default@3: + err // reject transaction + +main_bare_routing@5: + txn OnCompletion + bnz main_reject_bare_on_completion@7 + +main_create@6: + txn ApplicationID + ! + assert // is creating + int 1 + return + +main_reject_bare_on_completion@7: + err // reject transaction + + +// examples.hello_world.arc4_contract.HelloWorldContract.say_hello(name#0: bytes) -> void: +say_hello: + proto 1 0 + +say_hello_block@0: + frame_dig -1 + extract 2 0 + byte "Hello " + swap + concat + log + retsub + diff --git a/examples/hello_world/out/arc4_contract.approval_unoptimized.debug.teal b/examples/hello_world/out/arc4_contract.approval_unoptimized.debug.teal new file mode 100644 index 0000000000..cc2e6269ce --- /dev/null +++ b/examples/hello_world/out/arc4_contract.approval_unoptimized.debug.teal @@ -0,0 +1,69 @@ +// Op // Op Description Stack (out) Source code Source line + +#pragma version 8 + +// examples.hello_world.arc4_contract.HelloWorldContract.approval_program() -> uint64: +main_block@0: + txn NumAppArgs // {txn} class HelloWorldContract(ARC4Contract): File "hello_world/arc4_contract.py", line 5 + bz main_bare_routing@5 // class HelloWorldContract(ARC4Contract): File "hello_world/arc4_contract.py", line 5 + // Implicit fall through to main_abi_routing@1 // class HelloWorldContract(ARC4Contract): File "hello_world/arc4_contract.py", line 5 + +main_abi_routing@1: + txna ApplicationArgs 0 // {txna} class HelloWorldContract(ARC4Contract): File "hello_world/arc4_contract.py", line 5 + method "say_hello(string)void" // tmp%1#0,method<"say_hello(string)void"> abimethod File "hello_world/arc4_contract.py", line 7 + swap // load tmp%1#0 from l-stack (no copy) method<"say_hello(string)void">,tmp%1#0 class HelloWorldContract(ARC4Contract): File "hello_world/arc4_contract.py", line 5 + match main_say_hello_route@2 // class HelloWorldContract(ARC4Contract): File "hello_world/arc4_contract.py", line 5 + b main_switch_case_default@3 // class HelloWorldContract(ARC4Contract): File "hello_world/arc4_contract.py", line 5 + +main_say_hello_route@2: + txn OnCompletion // {txn} abimethod File "hello_world/arc4_contract.py", line 7 + int NoOp // tmp%2#0,NoOp abimethod File "hello_world/arc4_contract.py", line 7 + == // {==} abimethod File "hello_world/arc4_contract.py", line 7 + assert // OnCompletion is NoOp // abimethod File "hello_world/arc4_contract.py", line 7 + txn ApplicationID // {txn} abimethod File "hello_world/arc4_contract.py", line 7 + assert // is not creating // abimethod File "hello_world/arc4_contract.py", line 7 + txna ApplicationArgs 1 // {txna} class HelloWorldContract(ARC4Contract): File "hello_world/arc4_contract.py", line 5 + callsub say_hello // abimethod File "hello_world/arc4_contract.py", line 7 + int 1 // 1 abimethod File "hello_world/arc4_contract.py", line 7 + return // abimethod File "hello_world/arc4_contract.py", line 7 + +main_switch_case_default@3: + // Implicit fall through to main_switch_case_next@4 // + +main_switch_case_next@4: + b main_after_if_else@8 // + +main_bare_routing@5: + txn OnCompletion // {txn} class HelloWorldContract(ARC4Contract): File "hello_world/arc4_contract.py", line 5 + int 0 // tmp%6#0,0 class HelloWorldContract(ARC4Contract): File "hello_world/arc4_contract.py", line 5 + swap // load tmp%6#0 from l-stack (no copy) 0,tmp%6#0 class HelloWorldContract(ARC4Contract): File "hello_world/arc4_contract.py", line 5 + match main_create@6 // class HelloWorldContract(ARC4Contract): File "hello_world/arc4_contract.py", line 5 + b main_reject_bare_on_completion@7 // class HelloWorldContract(ARC4Contract): File "hello_world/arc4_contract.py", line 5 + +main_create@6: + txn ApplicationID // {txn} class HelloWorldContract(ARC4Contract): File "hello_world/arc4_contract.py", line 5 + ! // {!} class HelloWorldContract(ARC4Contract): File "hello_world/arc4_contract.py", line 5 + assert // is creating // class HelloWorldContract(ARC4Contract): File "hello_world/arc4_contract.py", line 5 + int 1 // 1 class HelloWorldContract(ARC4Contract): File "hello_world/arc4_contract.py", line 5 + return // class HelloWorldContract(ARC4Contract): File "hello_world/arc4_contract.py", line 5 + +main_reject_bare_on_completion@7: + err // reject transaction // class HelloWorldContract(ARC4Contract): File "hello_world/arc4_contract.py", line 5 + +main_after_if_else@8: + err // reject transaction // class HelloWorldContract(ARC4Contract): File "hello_world/arc4_contract.py", line 5 + + +// examples.hello_world.arc4_contract.HelloWorldContract.say_hello(name#0: bytes) -> void: +say_hello: + proto 1 0 // (𝕡) name#0 | def say_hello(self, name: String) -> None: File "hello_world/arc4_contract.py", line 8 + +say_hello_block@0: + frame_dig -1 // load name#0 from parameters (𝕡) name#0 | name#0 name: String File "hello_world/arc4_contract.py", line 8 + extract 2 0 // (𝕡) name#0 | {extract} name.decode() File "hello_world/arc4_contract.py", line 9 + byte "Hello " // (𝕡) name#0 | tmp%0#0,"Hello " b"Hello " File "hello_world/arc4_contract.py", line 9 + swap // load tmp%0#0 from l-stack (no copy) (𝕡) name#0 | "Hello ",tmp%0#0 name.decode() File "hello_world/arc4_contract.py", line 9 + concat // (𝕡) name#0 | {concat} Bytes(b"Hello ") + name.decode() File "hello_world/arc4_contract.py", line 9 + log // (𝕡) name#0 | log(Bytes(b"Hello ") + name.decode()) File "hello_world/arc4_contract.py", line 9 + retsub // + diff --git a/examples/hello_world/out/arc4_contract.approval_unoptimized.teal b/examples/hello_world/out/arc4_contract.approval_unoptimized.teal new file mode 100644 index 0000000000..d1372343e9 --- /dev/null +++ b/examples/hello_world/out/arc4_contract.approval_unoptimized.teal @@ -0,0 +1,65 @@ +#pragma version 8 + +// examples.hello_world.arc4_contract.HelloWorldContract.approval_program() -> uint64: +main_block@0: + txn NumAppArgs + bz main_bare_routing@5 + +main_abi_routing@1: + txna ApplicationArgs 0 + method "say_hello(string)void" + swap + match main_say_hello_route@2 + b main_switch_case_default@3 + +main_say_hello_route@2: + txn OnCompletion + int NoOp + == + assert // OnCompletion is NoOp + txn ApplicationID + assert // is not creating + txna ApplicationArgs 1 + callsub say_hello + int 1 + return + +main_switch_case_default@3: + +main_switch_case_next@4: + b main_after_if_else@8 + +main_bare_routing@5: + txn OnCompletion + int 0 + swap + match main_create@6 + b main_reject_bare_on_completion@7 + +main_create@6: + txn ApplicationID + ! + assert // is creating + int 1 + return + +main_reject_bare_on_completion@7: + err // reject transaction + +main_after_if_else@8: + err // reject transaction + + +// examples.hello_world.arc4_contract.HelloWorldContract.say_hello(name#0: bytes) -> void: +say_hello: + proto 1 0 + +say_hello_block@0: + frame_dig -1 + extract 2 0 + byte "Hello " + swap + concat + log + retsub + diff --git a/examples/hello_world/out/arc4_contract.awst b/examples/hello_world/out/arc4_contract.awst new file mode 100644 index 0000000000..618b09717a --- /dev/null +++ b/examples/hello_world/out/arc4_contract.awst @@ -0,0 +1,7 @@ +contract HelloWorldContract +{ + abimethod say_hello(name: puyapy.arc4.String): None + { + log('Hello ' + arc4_decode(name, puyapy.Bytes)) + } +} \ No newline at end of file diff --git a/examples/hello_world/out/arc4_contract.clear.debug.teal b/examples/hello_world/out/arc4_contract.clear.debug.teal new file mode 100644 index 0000000000..76e40a0fa9 --- /dev/null +++ b/examples/hello_world/out/arc4_contract.clear.debug.teal @@ -0,0 +1,9 @@ +// Op // Stack (out) Source code Source line + +#pragma version 8 + +// examples.hello_world.arc4_contract.HelloWorldContract.clear_state_program() -> uint64: +main_block@0: + int 1 // 1 class HelloWorldContract(ARC4Contract): File "hello_world/arc4_contract.py", line 5 + return // class HelloWorldContract(ARC4Contract): File "hello_world/arc4_contract.py", line 5 + diff --git a/examples/hello_world/out/arc4_contract.clear.teal b/examples/hello_world/out/arc4_contract.clear.teal new file mode 100644 index 0000000000..29de661cee --- /dev/null +++ b/examples/hello_world/out/arc4_contract.clear.teal @@ -0,0 +1,7 @@ +#pragma version 8 + +// examples.hello_world.arc4_contract.HelloWorldContract.clear_state_program() -> uint64: +main_block@0: + int 1 + return + diff --git a/examples/hello_world/out/arc4_contract.clear_unoptimized.debug.teal b/examples/hello_world/out/arc4_contract.clear_unoptimized.debug.teal new file mode 100644 index 0000000000..76e40a0fa9 --- /dev/null +++ b/examples/hello_world/out/arc4_contract.clear_unoptimized.debug.teal @@ -0,0 +1,9 @@ +// Op // Stack (out) Source code Source line + +#pragma version 8 + +// examples.hello_world.arc4_contract.HelloWorldContract.clear_state_program() -> uint64: +main_block@0: + int 1 // 1 class HelloWorldContract(ARC4Contract): File "hello_world/arc4_contract.py", line 5 + return // class HelloWorldContract(ARC4Contract): File "hello_world/arc4_contract.py", line 5 + diff --git a/examples/hello_world/out/arc4_contract.clear_unoptimized.teal b/examples/hello_world/out/arc4_contract.clear_unoptimized.teal new file mode 100644 index 0000000000..29de661cee --- /dev/null +++ b/examples/hello_world/out/arc4_contract.clear_unoptimized.teal @@ -0,0 +1,7 @@ +#pragma version 8 + +// examples.hello_world.arc4_contract.HelloWorldContract.clear_state_program() -> uint64: +main_block@0: + int 1 + return + diff --git a/examples/hello_world/out/arc4_contract_HelloWorldContract.cssa.ir b/examples/hello_world/out/arc4_contract_HelloWorldContract.cssa.ir new file mode 100644 index 0000000000..4184a35505 --- /dev/null +++ b/examples/hello_world/out/arc4_contract_HelloWorldContract.cssa.ir @@ -0,0 +1,42 @@ +contract examples.hello_world.arc4_contract.HelloWorldContract: + program approval: + subroutine examples.hello_world.arc4_contract.HelloWorldContract.approval_program() -> uint64: + block@0: // L5 + let tmp%0#0: uint64 = (txn NumAppArgs) + goto tmp%0#0 ? block@1 : block@5 + block@1: // abi_routing_L5 + let tmp%1#0: bytes = (txna ApplicationArgs 0) + switch tmp%1#0 {method "say_hello(string)void" => block@2, * => block@3} + block@2: // say_hello_route_L7 + let tmp%2#0: uint64 = (txn OnCompletion) + let tmp%3#0: uint64 = (! tmp%2#0) + (assert tmp%3#0) // OnCompletion is NoOp + let tmp%4#0: uint64 = (txn ApplicationID) + (assert tmp%4#0) // is not creating + let tmp%5#0: bytes = (txna ApplicationArgs 1) + examples.hello_world.arc4_contract.HelloWorldContract.say_hello(tmp%5#0) + return 1u + block@3: // switch_case_default_L5 + fail // reject transaction + block@5: // bare_routing_L5 + let tmp%6#0: uint64 = (txn OnCompletion) + goto tmp%6#0 ? block@7 : block@6 + block@6: // create_L5 + let tmp%7#0: uint64 = (txn ApplicationID) + let tmp%8#0: uint64 = (! tmp%7#0) + (assert tmp%8#0) // is creating + return 1u + block@7: // reject_bare_on_completion_L5 + fail // reject transaction + + subroutine examples.hello_world.arc4_contract.HelloWorldContract.say_hello(name: bytes) -> void: + block@0: // L8 + let tmp%0#0: bytes = ((extract 2 0) name#0) + let tmp%1#0: bytes = (concat "Hello " tmp%0#0) + (log tmp%1#0) + return + + program clear-state: + subroutine examples.hello_world.arc4_contract.HelloWorldContract.clear_state_program() -> uint64: + block@0: // L5 + return 1u \ No newline at end of file diff --git a/examples/hello_world/out/arc4_contract_HelloWorldContract.final.ir b/examples/hello_world/out/arc4_contract_HelloWorldContract.final.ir new file mode 100644 index 0000000000..4184a35505 --- /dev/null +++ b/examples/hello_world/out/arc4_contract_HelloWorldContract.final.ir @@ -0,0 +1,42 @@ +contract examples.hello_world.arc4_contract.HelloWorldContract: + program approval: + subroutine examples.hello_world.arc4_contract.HelloWorldContract.approval_program() -> uint64: + block@0: // L5 + let tmp%0#0: uint64 = (txn NumAppArgs) + goto tmp%0#0 ? block@1 : block@5 + block@1: // abi_routing_L5 + let tmp%1#0: bytes = (txna ApplicationArgs 0) + switch tmp%1#0 {method "say_hello(string)void" => block@2, * => block@3} + block@2: // say_hello_route_L7 + let tmp%2#0: uint64 = (txn OnCompletion) + let tmp%3#0: uint64 = (! tmp%2#0) + (assert tmp%3#0) // OnCompletion is NoOp + let tmp%4#0: uint64 = (txn ApplicationID) + (assert tmp%4#0) // is not creating + let tmp%5#0: bytes = (txna ApplicationArgs 1) + examples.hello_world.arc4_contract.HelloWorldContract.say_hello(tmp%5#0) + return 1u + block@3: // switch_case_default_L5 + fail // reject transaction + block@5: // bare_routing_L5 + let tmp%6#0: uint64 = (txn OnCompletion) + goto tmp%6#0 ? block@7 : block@6 + block@6: // create_L5 + let tmp%7#0: uint64 = (txn ApplicationID) + let tmp%8#0: uint64 = (! tmp%7#0) + (assert tmp%8#0) // is creating + return 1u + block@7: // reject_bare_on_completion_L5 + fail // reject transaction + + subroutine examples.hello_world.arc4_contract.HelloWorldContract.say_hello(name: bytes) -> void: + block@0: // L8 + let tmp%0#0: bytes = ((extract 2 0) name#0) + let tmp%1#0: bytes = (concat "Hello " tmp%0#0) + (log tmp%1#0) + return + + program clear-state: + subroutine examples.hello_world.arc4_contract.HelloWorldContract.clear_state_program() -> uint64: + block@0: // L5 + return 1u \ No newline at end of file diff --git a/examples/hello_world/out/arc4_contract_HelloWorldContract.final_unoptimized.ir b/examples/hello_world/out/arc4_contract_HelloWorldContract.final_unoptimized.ir new file mode 100644 index 0000000000..2236b9fc2e --- /dev/null +++ b/examples/hello_world/out/arc4_contract_HelloWorldContract.final_unoptimized.ir @@ -0,0 +1,46 @@ +contract examples.hello_world.arc4_contract.HelloWorldContract: + program approval: + subroutine examples.hello_world.arc4_contract.HelloWorldContract.approval_program() -> uint64: + block@0: // L5 + let tmp%0#0: uint64 = (txn NumAppArgs) + goto tmp%0#0 ? block@1 : block@5 + block@1: // abi_routing_L5 + let tmp%1#0: bytes = (txna ApplicationArgs 0) + switch tmp%1#0 {method "say_hello(string)void" => block@2, * => block@3} + block@2: // say_hello_route_L7 + let tmp%2#0: uint64 = (txn OnCompletion) + let tmp%3#0: uint64 = (== tmp%2#0 NoOp) + (assert tmp%3#0) // OnCompletion is NoOp + let tmp%4#0: uint64 = (txn ApplicationID) + (assert tmp%4#0) // is not creating + let tmp%5#0: bytes = (txna ApplicationArgs 1) + examples.hello_world.arc4_contract.HelloWorldContract.say_hello(tmp%5#0) + return 1u + block@3: // switch_case_default_L5 + goto block@4 + block@4: // switch_case_next_L5 + goto block@8 + block@5: // bare_routing_L5 + let tmp%6#0: uint64 = (txn OnCompletion) + switch tmp%6#0 {0u => block@6, * => block@7} + block@6: // create_L5 + let tmp%7#0: uint64 = (txn ApplicationID) + let tmp%8#0: uint64 = (! tmp%7#0) + (assert tmp%8#0) // is creating + return 1u + block@7: // reject_bare_on_completion_L5 + fail // reject transaction + block@8: // after_if_else_L5 + fail // reject transaction + + subroutine examples.hello_world.arc4_contract.HelloWorldContract.say_hello(name: bytes) -> void: + block@0: // L8 + let tmp%0#0: bytes = ((extract 2 0) name#0) + let tmp%1#0: bytes = (concat "Hello " tmp%0#0) + (log tmp%1#0) + return + + program clear-state: + subroutine examples.hello_world.arc4_contract.HelloWorldContract.clear_state_program() -> uint64: + block@0: // L5 + return 1u \ No newline at end of file diff --git a/examples/hello_world/out/arc4_contract_HelloWorldContract.parallel_copies.ir b/examples/hello_world/out/arc4_contract_HelloWorldContract.parallel_copies.ir new file mode 100644 index 0000000000..4184a35505 --- /dev/null +++ b/examples/hello_world/out/arc4_contract_HelloWorldContract.parallel_copies.ir @@ -0,0 +1,42 @@ +contract examples.hello_world.arc4_contract.HelloWorldContract: + program approval: + subroutine examples.hello_world.arc4_contract.HelloWorldContract.approval_program() -> uint64: + block@0: // L5 + let tmp%0#0: uint64 = (txn NumAppArgs) + goto tmp%0#0 ? block@1 : block@5 + block@1: // abi_routing_L5 + let tmp%1#0: bytes = (txna ApplicationArgs 0) + switch tmp%1#0 {method "say_hello(string)void" => block@2, * => block@3} + block@2: // say_hello_route_L7 + let tmp%2#0: uint64 = (txn OnCompletion) + let tmp%3#0: uint64 = (! tmp%2#0) + (assert tmp%3#0) // OnCompletion is NoOp + let tmp%4#0: uint64 = (txn ApplicationID) + (assert tmp%4#0) // is not creating + let tmp%5#0: bytes = (txna ApplicationArgs 1) + examples.hello_world.arc4_contract.HelloWorldContract.say_hello(tmp%5#0) + return 1u + block@3: // switch_case_default_L5 + fail // reject transaction + block@5: // bare_routing_L5 + let tmp%6#0: uint64 = (txn OnCompletion) + goto tmp%6#0 ? block@7 : block@6 + block@6: // create_L5 + let tmp%7#0: uint64 = (txn ApplicationID) + let tmp%8#0: uint64 = (! tmp%7#0) + (assert tmp%8#0) // is creating + return 1u + block@7: // reject_bare_on_completion_L5 + fail // reject transaction + + subroutine examples.hello_world.arc4_contract.HelloWorldContract.say_hello(name: bytes) -> void: + block@0: // L8 + let tmp%0#0: bytes = ((extract 2 0) name#0) + let tmp%1#0: bytes = (concat "Hello " tmp%0#0) + (log tmp%1#0) + return + + program clear-state: + subroutine examples.hello_world.arc4_contract.HelloWorldContract.clear_state_program() -> uint64: + block@0: // L5 + return 1u \ No newline at end of file diff --git a/examples/hello_world/out/arc4_contract_HelloWorldContract.post_ssa.ir b/examples/hello_world/out/arc4_contract_HelloWorldContract.post_ssa.ir new file mode 100644 index 0000000000..4184a35505 --- /dev/null +++ b/examples/hello_world/out/arc4_contract_HelloWorldContract.post_ssa.ir @@ -0,0 +1,42 @@ +contract examples.hello_world.arc4_contract.HelloWorldContract: + program approval: + subroutine examples.hello_world.arc4_contract.HelloWorldContract.approval_program() -> uint64: + block@0: // L5 + let tmp%0#0: uint64 = (txn NumAppArgs) + goto tmp%0#0 ? block@1 : block@5 + block@1: // abi_routing_L5 + let tmp%1#0: bytes = (txna ApplicationArgs 0) + switch tmp%1#0 {method "say_hello(string)void" => block@2, * => block@3} + block@2: // say_hello_route_L7 + let tmp%2#0: uint64 = (txn OnCompletion) + let tmp%3#0: uint64 = (! tmp%2#0) + (assert tmp%3#0) // OnCompletion is NoOp + let tmp%4#0: uint64 = (txn ApplicationID) + (assert tmp%4#0) // is not creating + let tmp%5#0: bytes = (txna ApplicationArgs 1) + examples.hello_world.arc4_contract.HelloWorldContract.say_hello(tmp%5#0) + return 1u + block@3: // switch_case_default_L5 + fail // reject transaction + block@5: // bare_routing_L5 + let tmp%6#0: uint64 = (txn OnCompletion) + goto tmp%6#0 ? block@7 : block@6 + block@6: // create_L5 + let tmp%7#0: uint64 = (txn ApplicationID) + let tmp%8#0: uint64 = (! tmp%7#0) + (assert tmp%8#0) // is creating + return 1u + block@7: // reject_bare_on_completion_L5 + fail // reject transaction + + subroutine examples.hello_world.arc4_contract.HelloWorldContract.say_hello(name: bytes) -> void: + block@0: // L8 + let tmp%0#0: bytes = ((extract 2 0) name#0) + let tmp%1#0: bytes = (concat "Hello " tmp%0#0) + (log tmp%1#0) + return + + program clear-state: + subroutine examples.hello_world.arc4_contract.HelloWorldContract.clear_state_program() -> uint64: + block@0: // L5 + return 1u \ No newline at end of file diff --git a/examples/hello_world/out/arc4_contract_HelloWorldContract.ssa.ir b/examples/hello_world/out/arc4_contract_HelloWorldContract.ssa.ir new file mode 100644 index 0000000000..2236b9fc2e --- /dev/null +++ b/examples/hello_world/out/arc4_contract_HelloWorldContract.ssa.ir @@ -0,0 +1,46 @@ +contract examples.hello_world.arc4_contract.HelloWorldContract: + program approval: + subroutine examples.hello_world.arc4_contract.HelloWorldContract.approval_program() -> uint64: + block@0: // L5 + let tmp%0#0: uint64 = (txn NumAppArgs) + goto tmp%0#0 ? block@1 : block@5 + block@1: // abi_routing_L5 + let tmp%1#0: bytes = (txna ApplicationArgs 0) + switch tmp%1#0 {method "say_hello(string)void" => block@2, * => block@3} + block@2: // say_hello_route_L7 + let tmp%2#0: uint64 = (txn OnCompletion) + let tmp%3#0: uint64 = (== tmp%2#0 NoOp) + (assert tmp%3#0) // OnCompletion is NoOp + let tmp%4#0: uint64 = (txn ApplicationID) + (assert tmp%4#0) // is not creating + let tmp%5#0: bytes = (txna ApplicationArgs 1) + examples.hello_world.arc4_contract.HelloWorldContract.say_hello(tmp%5#0) + return 1u + block@3: // switch_case_default_L5 + goto block@4 + block@4: // switch_case_next_L5 + goto block@8 + block@5: // bare_routing_L5 + let tmp%6#0: uint64 = (txn OnCompletion) + switch tmp%6#0 {0u => block@6, * => block@7} + block@6: // create_L5 + let tmp%7#0: uint64 = (txn ApplicationID) + let tmp%8#0: uint64 = (! tmp%7#0) + (assert tmp%8#0) // is creating + return 1u + block@7: // reject_bare_on_completion_L5 + fail // reject transaction + block@8: // after_if_else_L5 + fail // reject transaction + + subroutine examples.hello_world.arc4_contract.HelloWorldContract.say_hello(name: bytes) -> void: + block@0: // L8 + let tmp%0#0: bytes = ((extract 2 0) name#0) + let tmp%1#0: bytes = (concat "Hello " tmp%0#0) + (log tmp%1#0) + return + + program clear-state: + subroutine examples.hello_world.arc4_contract.HelloWorldContract.clear_state_program() -> uint64: + block@0: // L5 + return 1u \ No newline at end of file diff --git a/examples/hello_world/out/arc4_contract_HelloWorldContract.ssa.opt_pass_1.ir b/examples/hello_world/out/arc4_contract_HelloWorldContract.ssa.opt_pass_1.ir new file mode 100644 index 0000000000..8634b15771 --- /dev/null +++ b/examples/hello_world/out/arc4_contract_HelloWorldContract.ssa.opt_pass_1.ir @@ -0,0 +1,42 @@ +contract examples.hello_world.arc4_contract.HelloWorldContract: + program approval: + subroutine examples.hello_world.arc4_contract.HelloWorldContract.approval_program() -> uint64: + block@0: // L5 + let tmp%0#0: uint64 = (txn NumAppArgs) + goto tmp%0#0 ? block@1 : block@5 + block@1: // abi_routing_L5 + let tmp%1#0: bytes = (txna ApplicationArgs 0) + switch tmp%1#0 {method "say_hello(string)void" => block@2, * => block@3} + block@2: // say_hello_route_L7 + let tmp%2#0: uint64 = (txn OnCompletion) + let tmp%3#0: uint64 = (! tmp%2#0) + (assert tmp%3#0) // OnCompletion is NoOp + let tmp%4#0: uint64 = (txn ApplicationID) + (assert tmp%4#0) // is not creating + let tmp%5#0: bytes = (txna ApplicationArgs 1) + examples.hello_world.arc4_contract.HelloWorldContract.say_hello(tmp%5#0) + return 1u + block@3: // switch_case_default_L5 + fail // reject transaction + block@5: // bare_routing_L5 + let tmp%6#0: uint64 = (txn OnCompletion) + goto [block@6, ...block@7][tmp%6#0] + block@6: // create_L5 + let tmp%7#0: uint64 = (txn ApplicationID) + let tmp%8#0: uint64 = (! tmp%7#0) + (assert tmp%8#0) // is creating + return 1u + block@7: // reject_bare_on_completion_L5 + fail // reject transaction + + subroutine examples.hello_world.arc4_contract.HelloWorldContract.say_hello(name: bytes) -> void: + block@0: // L8 + let tmp%0#0: bytes = ((extract 2 0) name#0) + let tmp%1#0: bytes = (concat "Hello " tmp%0#0) + (log tmp%1#0) + return + + program clear-state: + subroutine examples.hello_world.arc4_contract.HelloWorldContract.clear_state_program() -> uint64: + block@0: // L5 + return 1u \ No newline at end of file diff --git a/examples/hello_world/out/arc4_contract_HelloWorldContract.ssa.opt_pass_2.ir b/examples/hello_world/out/arc4_contract_HelloWorldContract.ssa.opt_pass_2.ir new file mode 100644 index 0000000000..4184a35505 --- /dev/null +++ b/examples/hello_world/out/arc4_contract_HelloWorldContract.ssa.opt_pass_2.ir @@ -0,0 +1,42 @@ +contract examples.hello_world.arc4_contract.HelloWorldContract: + program approval: + subroutine examples.hello_world.arc4_contract.HelloWorldContract.approval_program() -> uint64: + block@0: // L5 + let tmp%0#0: uint64 = (txn NumAppArgs) + goto tmp%0#0 ? block@1 : block@5 + block@1: // abi_routing_L5 + let tmp%1#0: bytes = (txna ApplicationArgs 0) + switch tmp%1#0 {method "say_hello(string)void" => block@2, * => block@3} + block@2: // say_hello_route_L7 + let tmp%2#0: uint64 = (txn OnCompletion) + let tmp%3#0: uint64 = (! tmp%2#0) + (assert tmp%3#0) // OnCompletion is NoOp + let tmp%4#0: uint64 = (txn ApplicationID) + (assert tmp%4#0) // is not creating + let tmp%5#0: bytes = (txna ApplicationArgs 1) + examples.hello_world.arc4_contract.HelloWorldContract.say_hello(tmp%5#0) + return 1u + block@3: // switch_case_default_L5 + fail // reject transaction + block@5: // bare_routing_L5 + let tmp%6#0: uint64 = (txn OnCompletion) + goto tmp%6#0 ? block@7 : block@6 + block@6: // create_L5 + let tmp%7#0: uint64 = (txn ApplicationID) + let tmp%8#0: uint64 = (! tmp%7#0) + (assert tmp%8#0) // is creating + return 1u + block@7: // reject_bare_on_completion_L5 + fail // reject transaction + + subroutine examples.hello_world.arc4_contract.HelloWorldContract.say_hello(name: bytes) -> void: + block@0: // L8 + let tmp%0#0: bytes = ((extract 2 0) name#0) + let tmp%1#0: bytes = (concat "Hello " tmp%0#0) + (log tmp%1#0) + return + + program clear-state: + subroutine examples.hello_world.arc4_contract.HelloWorldContract.clear_state_program() -> uint64: + block@0: // L5 + return 1u \ No newline at end of file diff --git a/examples/hello_world/out/contract.approval.debug.teal b/examples/hello_world/out/contract.approval.debug.teal new file mode 100644 index 0000000000..26e5d032cb --- /dev/null +++ b/examples/hello_world/out/contract.approval.debug.teal @@ -0,0 +1,14 @@ +// Op // Op Description Stack (out) Source code Source line + +#pragma version 8 + +// examples.hello_world.contract.HelloWorldContract.approval_program() -> uint64: +main_block@0: + txna ApplicationArgs 0 // {txna} Transaction.application_args(0) File "hello_world/contract.py", line 7 + byte "Hello " // name#0,"Hello " b"Hello " File "hello_world/contract.py", line 8 + swap // load name#0 from l-stack (no copy) "Hello ",name#0 name File "hello_world/contract.py", line 7 + concat // {concat} Bytes(b"Hello ") + name File "hello_world/contract.py", line 8 + log // log(Bytes(b"Hello ") + name) File "hello_world/contract.py", line 8 + int 1 // 1 True File "hello_world/contract.py", line 9 + return // return True File "hello_world/contract.py", line 9 + diff --git a/examples/hello_world/out/contract.approval.teal b/examples/hello_world/out/contract.approval.teal new file mode 100644 index 0000000000..40974a4f50 --- /dev/null +++ b/examples/hello_world/out/contract.approval.teal @@ -0,0 +1,12 @@ +#pragma version 8 + +// examples.hello_world.contract.HelloWorldContract.approval_program() -> uint64: +main_block@0: + txna ApplicationArgs 0 + byte "Hello " + swap + concat + log + int 1 + return + diff --git a/examples/hello_world/out/contract.approval_unoptimized.debug.teal b/examples/hello_world/out/contract.approval_unoptimized.debug.teal new file mode 100644 index 0000000000..26e5d032cb --- /dev/null +++ b/examples/hello_world/out/contract.approval_unoptimized.debug.teal @@ -0,0 +1,14 @@ +// Op // Op Description Stack (out) Source code Source line + +#pragma version 8 + +// examples.hello_world.contract.HelloWorldContract.approval_program() -> uint64: +main_block@0: + txna ApplicationArgs 0 // {txna} Transaction.application_args(0) File "hello_world/contract.py", line 7 + byte "Hello " // name#0,"Hello " b"Hello " File "hello_world/contract.py", line 8 + swap // load name#0 from l-stack (no copy) "Hello ",name#0 name File "hello_world/contract.py", line 7 + concat // {concat} Bytes(b"Hello ") + name File "hello_world/contract.py", line 8 + log // log(Bytes(b"Hello ") + name) File "hello_world/contract.py", line 8 + int 1 // 1 True File "hello_world/contract.py", line 9 + return // return True File "hello_world/contract.py", line 9 + diff --git a/examples/hello_world/out/contract.approval_unoptimized.teal b/examples/hello_world/out/contract.approval_unoptimized.teal new file mode 100644 index 0000000000..40974a4f50 --- /dev/null +++ b/examples/hello_world/out/contract.approval_unoptimized.teal @@ -0,0 +1,12 @@ +#pragma version 8 + +// examples.hello_world.contract.HelloWorldContract.approval_program() -> uint64: +main_block@0: + txna ApplicationArgs 0 + byte "Hello " + swap + concat + log + int 1 + return + diff --git a/examples/hello_world/out/contract.awst b/examples/hello_world/out/contract.awst new file mode 100644 index 0000000000..68a56dfc36 --- /dev/null +++ b/examples/hello_world/out/contract.awst @@ -0,0 +1,14 @@ +contract HelloWorldContract +{ + approval_program(): bool + { + name: puyapy.Bytes = txna() + log('Hello ' + name) + return true + } + + clear_state_program(): bool + { + return true + } +} \ No newline at end of file diff --git a/examples/hello_world/out/contract.clear.debug.teal b/examples/hello_world/out/contract.clear.debug.teal new file mode 100644 index 0000000000..7cfc680476 --- /dev/null +++ b/examples/hello_world/out/contract.clear.debug.teal @@ -0,0 +1,9 @@ +// Op // Stack (out) Source code Source line + +#pragma version 8 + +// examples.hello_world.contract.HelloWorldContract.clear_state_program() -> uint64: +main_block@0: + int 1 // 1 True File "hello_world/contract.py", line 12 + return // return True File "hello_world/contract.py", line 12 + diff --git a/examples/hello_world/out/contract.clear.teal b/examples/hello_world/out/contract.clear.teal new file mode 100644 index 0000000000..b25c33953a --- /dev/null +++ b/examples/hello_world/out/contract.clear.teal @@ -0,0 +1,7 @@ +#pragma version 8 + +// examples.hello_world.contract.HelloWorldContract.clear_state_program() -> uint64: +main_block@0: + int 1 + return + diff --git a/examples/hello_world/out/contract.clear_unoptimized.debug.teal b/examples/hello_world/out/contract.clear_unoptimized.debug.teal new file mode 100644 index 0000000000..7cfc680476 --- /dev/null +++ b/examples/hello_world/out/contract.clear_unoptimized.debug.teal @@ -0,0 +1,9 @@ +// Op // Stack (out) Source code Source line + +#pragma version 8 + +// examples.hello_world.contract.HelloWorldContract.clear_state_program() -> uint64: +main_block@0: + int 1 // 1 True File "hello_world/contract.py", line 12 + return // return True File "hello_world/contract.py", line 12 + diff --git a/examples/hello_world/out/contract.clear_unoptimized.teal b/examples/hello_world/out/contract.clear_unoptimized.teal new file mode 100644 index 0000000000..b25c33953a --- /dev/null +++ b/examples/hello_world/out/contract.clear_unoptimized.teal @@ -0,0 +1,7 @@ +#pragma version 8 + +// examples.hello_world.contract.HelloWorldContract.clear_state_program() -> uint64: +main_block@0: + int 1 + return + diff --git a/examples/hello_world/out/contract_HelloWorldContract.cssa.ir b/examples/hello_world/out/contract_HelloWorldContract.cssa.ir new file mode 100644 index 0000000000..73512ff367 --- /dev/null +++ b/examples/hello_world/out/contract_HelloWorldContract.cssa.ir @@ -0,0 +1,13 @@ +contract examples.hello_world.contract.HelloWorldContract: + program approval: + subroutine examples.hello_world.contract.HelloWorldContract.approval_program() -> uint64: + block@0: // L6 + let name#0: bytes = (txna ApplicationArgs 0) + let tmp%0#0: bytes = (concat "Hello " name#0) + (log tmp%0#0) + return 1u + + program clear-state: + subroutine examples.hello_world.contract.HelloWorldContract.clear_state_program() -> uint64: + block@0: // L11 + return 1u \ No newline at end of file diff --git a/examples/hello_world/out/contract_HelloWorldContract.final.ir b/examples/hello_world/out/contract_HelloWorldContract.final.ir new file mode 100644 index 0000000000..73512ff367 --- /dev/null +++ b/examples/hello_world/out/contract_HelloWorldContract.final.ir @@ -0,0 +1,13 @@ +contract examples.hello_world.contract.HelloWorldContract: + program approval: + subroutine examples.hello_world.contract.HelloWorldContract.approval_program() -> uint64: + block@0: // L6 + let name#0: bytes = (txna ApplicationArgs 0) + let tmp%0#0: bytes = (concat "Hello " name#0) + (log tmp%0#0) + return 1u + + program clear-state: + subroutine examples.hello_world.contract.HelloWorldContract.clear_state_program() -> uint64: + block@0: // L11 + return 1u \ No newline at end of file diff --git a/examples/hello_world/out/contract_HelloWorldContract.final_unoptimized.ir b/examples/hello_world/out/contract_HelloWorldContract.final_unoptimized.ir new file mode 100644 index 0000000000..73512ff367 --- /dev/null +++ b/examples/hello_world/out/contract_HelloWorldContract.final_unoptimized.ir @@ -0,0 +1,13 @@ +contract examples.hello_world.contract.HelloWorldContract: + program approval: + subroutine examples.hello_world.contract.HelloWorldContract.approval_program() -> uint64: + block@0: // L6 + let name#0: bytes = (txna ApplicationArgs 0) + let tmp%0#0: bytes = (concat "Hello " name#0) + (log tmp%0#0) + return 1u + + program clear-state: + subroutine examples.hello_world.contract.HelloWorldContract.clear_state_program() -> uint64: + block@0: // L11 + return 1u \ No newline at end of file diff --git a/examples/hello_world/out/contract_HelloWorldContract.parallel_copies.ir b/examples/hello_world/out/contract_HelloWorldContract.parallel_copies.ir new file mode 100644 index 0000000000..73512ff367 --- /dev/null +++ b/examples/hello_world/out/contract_HelloWorldContract.parallel_copies.ir @@ -0,0 +1,13 @@ +contract examples.hello_world.contract.HelloWorldContract: + program approval: + subroutine examples.hello_world.contract.HelloWorldContract.approval_program() -> uint64: + block@0: // L6 + let name#0: bytes = (txna ApplicationArgs 0) + let tmp%0#0: bytes = (concat "Hello " name#0) + (log tmp%0#0) + return 1u + + program clear-state: + subroutine examples.hello_world.contract.HelloWorldContract.clear_state_program() -> uint64: + block@0: // L11 + return 1u \ No newline at end of file diff --git a/examples/hello_world/out/contract_HelloWorldContract.post_ssa.ir b/examples/hello_world/out/contract_HelloWorldContract.post_ssa.ir new file mode 100644 index 0000000000..73512ff367 --- /dev/null +++ b/examples/hello_world/out/contract_HelloWorldContract.post_ssa.ir @@ -0,0 +1,13 @@ +contract examples.hello_world.contract.HelloWorldContract: + program approval: + subroutine examples.hello_world.contract.HelloWorldContract.approval_program() -> uint64: + block@0: // L6 + let name#0: bytes = (txna ApplicationArgs 0) + let tmp%0#0: bytes = (concat "Hello " name#0) + (log tmp%0#0) + return 1u + + program clear-state: + subroutine examples.hello_world.contract.HelloWorldContract.clear_state_program() -> uint64: + block@0: // L11 + return 1u \ No newline at end of file diff --git a/examples/hello_world/out/contract_HelloWorldContract.ssa.ir b/examples/hello_world/out/contract_HelloWorldContract.ssa.ir new file mode 100644 index 0000000000..73512ff367 --- /dev/null +++ b/examples/hello_world/out/contract_HelloWorldContract.ssa.ir @@ -0,0 +1,13 @@ +contract examples.hello_world.contract.HelloWorldContract: + program approval: + subroutine examples.hello_world.contract.HelloWorldContract.approval_program() -> uint64: + block@0: // L6 + let name#0: bytes = (txna ApplicationArgs 0) + let tmp%0#0: bytes = (concat "Hello " name#0) + (log tmp%0#0) + return 1u + + program clear-state: + subroutine examples.hello_world.contract.HelloWorldContract.clear_state_program() -> uint64: + block@0: // L11 + return 1u \ No newline at end of file diff --git a/examples/hello_world/puya.log b/examples/hello_world/puya.log new file mode 100644 index 0000000000..fc38312696 --- /dev/null +++ b/examples/hello_world/puya.log @@ -0,0 +1,233 @@ +>> poetry run puyapy -O1 --output-ssa-ir --output-optimization-ir --output-final-ir --output-cssa-ir --output-post-ssa-ir --output-parallel-copies-ir --out-dir=out --debug-level=1 --log-level=debug hello_world +Configuration file exists at /Users/danielm/Library/Preferences/pypoetry, reusing this directory. + +Consider moving TOML configuration files to /Users/danielm/Library/Application Support/pypoetry, as support for the legacy directory will be removed in an upcoming release. +debug: Building AWST for __init__.py +debug: Building AWST for hello_world +debug: Building AWST for embedded puyapy lib at /puyapy.py +debug: Building AWST for hello_world/contract.py +debug: Building AWST for hello_world/arc4_contract.py +debug: Sealing block@0: // L6 +debug: Terminated block@0: // L6 +debug: Sealing block@0: // L11 +debug: Terminated block@0: // L11 +debug: Sealing block@0: // L8 +debug: Terminated block@0: // L8 +debug: Sealing block@0: // L5 +debug: Terminated block@0: // L5 +debug: Sealing block@None: // abi_routing_L5 +debug: Sealing block@None: // bare_routing_L5 +debug: Terminated block@1: // abi_routing_L5 +debug: Sealing block@None: // switch_case_default_L5 +debug: Sealing block@None: // say_hello_route_L7 +debug: Terminated block@2: // say_hello_route_L7 +debug: Terminated block@3: // switch_case_default_L5 +debug: Sealing block@4: // switch_case_next_L5 +debug: Terminated block@4: // switch_case_next_L5 +debug: Terminated block@5: // bare_routing_L5 +debug: Sealing block@None: // reject_bare_on_completion_L5 +debug: Sealing block@None: // create_L5 +debug: Terminated block@6: // create_L5 +debug: Terminated block@7: // reject_bare_on_completion_L5 +debug: Sealing block@None: // switch_case_next_L5 +debug: Sealing block@8: // after_if_else_L5 +debug: Terminated block@8: // after_if_else_L5 +debug: Sealing block@0: // L5 +debug: Terminated block@0: // L5 +debug: Output IR to /examples/hello_world/out/arc4_contract_HelloWorldContract.ssa.ir +info: Optimizing examples.hello_world.arc4_contract.HelloWorldContract at level 1 +debug: Begin optimization pass 1/100 +debug: Optimizing subroutine examples.hello_world.arc4_contract.HelloWorldContract.approval_program +debug: Splitting parallel copies prior to optimization +debug: Optimizer: Arithmetic Simplification +debug: Optimizer: Constant Replacer +debug: Optimizer: Copy Propagation +debug: Optimizer: Intrinsic Simplifier +debug: Optimizer: Remove Unused Variables +debug: Optimizer: Simplify Conditional Branches +debug: Switch switch tmp%6#0 {0u => block@6, * => block@7} simplified to goto [block@6, ...block@7][tmp%6#0] +debug: Optimizer: Remove Linear Jump +debug: Replaced predecessor block@4: // switch_case_next_L5 with block@3: // switch_case_default_L5 in block@8: // after_if_else_L5 +debug: Merged linear block@4: // switch_case_next_L5 into block@3: // switch_case_default_L5 +debug: Merged linear block@8: // after_if_else_L5 into block@3: // switch_case_default_L5 +debug: Optimizer: Remove Empty Blocks +debug: Optimizer: Remove Unreachable Blocks +debug: Optimizing subroutine examples.hello_world.arc4_contract.HelloWorldContract.say_hello +debug: Splitting parallel copies prior to optimization +debug: Optimizer: Arithmetic Simplification +debug: Optimizer: Constant Replacer +debug: Optimizer: Copy Propagation +debug: Optimizer: Intrinsic Simplifier +debug: Optimizer: Remove Unused Variables +debug: Optimizer: Simplify Conditional Branches +debug: Optimizer: Remove Linear Jump +debug: Optimizer: Remove Empty Blocks +debug: Optimizer: Remove Unreachable Blocks +debug: Optimizing subroutine examples.hello_world.arc4_contract.HelloWorldContract.clear_state_program +debug: Splitting parallel copies prior to optimization +debug: Optimizer: Arithmetic Simplification +debug: Optimizer: Constant Replacer +debug: Optimizer: Copy Propagation +debug: Optimizer: Intrinsic Simplifier +debug: Optimizer: Remove Unused Variables +debug: Optimizer: Simplify Conditional Branches +debug: Optimizer: Remove Linear Jump +debug: Optimizer: Remove Empty Blocks +debug: Optimizer: Remove Unreachable Blocks +debug: Output IR to /examples/hello_world/out/arc4_contract_HelloWorldContract.ssa.opt_pass_1.ir +debug: Begin optimization pass 2/100 +debug: Optimizing subroutine examples.hello_world.arc4_contract.HelloWorldContract.approval_program +debug: Optimizer: Arithmetic Simplification +debug: Optimizer: Constant Replacer +debug: Optimizer: Copy Propagation +debug: Optimizer: Intrinsic Simplifier +debug: Optimizer: Remove Unused Variables +debug: Optimizer: Simplify Conditional Branches +debug: GotoNth goto [block@6, ...block@7][tmp%6#0] simplified to goto tmp%6#0 ? block@7 : block@6 +debug: Optimizer: Remove Linear Jump +debug: Optimizer: Remove Empty Blocks +debug: Optimizer: Remove Unreachable Blocks +debug: Optimizing subroutine examples.hello_world.arc4_contract.HelloWorldContract.say_hello +debug: Optimizer: Arithmetic Simplification +debug: Optimizer: Constant Replacer +debug: Optimizer: Copy Propagation +debug: Optimizer: Intrinsic Simplifier +debug: Optimizer: Remove Unused Variables +debug: Optimizer: Simplify Conditional Branches +debug: Optimizer: Remove Linear Jump +debug: Optimizer: Remove Empty Blocks +debug: Optimizer: Remove Unreachable Blocks +debug: Optimizing subroutine examples.hello_world.arc4_contract.HelloWorldContract.clear_state_program +debug: Optimizer: Arithmetic Simplification +debug: Optimizer: Constant Replacer +debug: Optimizer: Copy Propagation +debug: Optimizer: Intrinsic Simplifier +debug: Optimizer: Remove Unused Variables +debug: Optimizer: Simplify Conditional Branches +debug: Optimizer: Remove Linear Jump +debug: Optimizer: Remove Empty Blocks +debug: Optimizer: Remove Unreachable Blocks +debug: Output IR to /examples/hello_world/out/arc4_contract_HelloWorldContract.ssa.opt_pass_2.ir +debug: Begin optimization pass 3/100 +debug: Optimizing subroutine examples.hello_world.arc4_contract.HelloWorldContract.approval_program +debug: Optimizer: Arithmetic Simplification +debug: Optimizer: Constant Replacer +debug: Optimizer: Copy Propagation +debug: Optimizer: Intrinsic Simplifier +debug: Optimizer: Remove Unused Variables +debug: Optimizer: Simplify Conditional Branches +debug: Optimizer: Remove Linear Jump +debug: Optimizer: Remove Empty Blocks +debug: Optimizer: Remove Unreachable Blocks +debug: Optimizing subroutine examples.hello_world.arc4_contract.HelloWorldContract.say_hello +debug: Optimizer: Arithmetic Simplification +debug: Optimizer: Constant Replacer +debug: Optimizer: Copy Propagation +debug: Optimizer: Intrinsic Simplifier +debug: Optimizer: Remove Unused Variables +debug: Optimizer: Simplify Conditional Branches +debug: Optimizer: Remove Linear Jump +debug: Optimizer: Remove Empty Blocks +debug: Optimizer: Remove Unreachable Blocks +debug: Optimizing subroutine examples.hello_world.arc4_contract.HelloWorldContract.clear_state_program +debug: Optimizer: Arithmetic Simplification +debug: Optimizer: Constant Replacer +debug: Optimizer: Copy Propagation +debug: Optimizer: Intrinsic Simplifier +debug: Optimizer: Remove Unused Variables +debug: Optimizer: Simplify Conditional Branches +debug: Optimizer: Remove Linear Jump +debug: Optimizer: Remove Empty Blocks +debug: Optimizer: Remove Unreachable Blocks +debug: No optimizations performed in pass 3, ending loop +debug: Output IR to /examples/hello_world/out/arc4_contract_HelloWorldContract.cssa.ir +debug: Removing Phis from examples.hello_world.arc4_contract.HelloWorldContract.approval_program +debug: Removing Phis from examples.hello_world.arc4_contract.HelloWorldContract.say_hello +debug: Removing Phis from examples.hello_world.arc4_contract.HelloWorldContract.clear_state_program +debug: Output IR to /examples/hello_world/out/arc4_contract_HelloWorldContract.post_ssa.ir +debug: Sequentializing parallel copies in examples.hello_world.arc4_contract.HelloWorldContract.approval_program +debug: Sequentializing parallel copies in examples.hello_world.arc4_contract.HelloWorldContract.say_hello +debug: Sequentializing parallel copies in examples.hello_world.arc4_contract.HelloWorldContract.clear_state_program +debug: Output IR to /examples/hello_world/out/arc4_contract_HelloWorldContract.parallel_copies.ir +debug: Coalescing local variables in examples.hello_world.arc4_contract.HelloWorldContract.approval_program using strategy RootOperandGrouping +debug: Coalescing resulted in 0 replacement/s +debug: Coalescing local variables in examples.hello_world.arc4_contract.HelloWorldContract.say_hello using strategy RootOperandGrouping +debug: Coalescing resulted in 0 replacement/s +debug: Coalescing local variables in examples.hello_world.arc4_contract.HelloWorldContract.clear_state_program using strategy RootOperandGrouping +debug: Coalescing resulted in 0 replacement/s +debug: Output IR to /examples/hello_world/out/arc4_contract_HelloWorldContract.final.ir +debug: Inserted main_block@0.ops[1]: 'store tmp%0#0 to l-stack (copy)' +debug: Replaced main_block@0.ops[3]: 'load tmp%0#0' with 'load tmp%0#0 from l-stack (no copy)' +debug: Inserted main_abi_routing@1.ops[1]: 'store tmp%1#0 to l-stack (copy)' +debug: Replaced main_abi_routing@1.ops[4]: 'load tmp%1#0' with 'load tmp%1#0 from l-stack (no copy)' +debug: Inserted main_say_hello_route@2.ops[1]: 'store tmp%2#0 to l-stack (copy)' +debug: Replaced main_say_hello_route@2.ops[3]: 'load tmp%2#0' with 'load tmp%2#0 from l-stack (no copy)' +debug: Inserted main_say_hello_route@2.ops[5]: 'store tmp%3#0 to l-stack (copy)' +debug: Replaced main_say_hello_route@2.ops[7]: 'load tmp%3#0' with 'load tmp%3#0 from l-stack (no copy)' +debug: Inserted main_say_hello_route@2.ops[10]: 'store tmp%4#0 to l-stack (copy)' +debug: Replaced main_say_hello_route@2.ops[12]: 'load tmp%4#0' with 'load tmp%4#0 from l-stack (no copy)' +debug: Inserted main_say_hello_route@2.ops[15]: 'store tmp%5#0 to l-stack (copy)' +debug: Replaced main_say_hello_route@2.ops[17]: 'load tmp%5#0' with 'load tmp%5#0 from l-stack (no copy)' +debug: Inserted main_bare_routing@5.ops[1]: 'store tmp%6#0 to l-stack (copy)' +debug: Replaced main_bare_routing@5.ops[3]: 'load tmp%6#0' with 'load tmp%6#0 from l-stack (no copy)' +debug: Inserted main_create@6.ops[1]: 'store tmp%7#0 to l-stack (copy)' +debug: Replaced main_create@6.ops[3]: 'load tmp%7#0' with 'load tmp%7#0 from l-stack (no copy)' +debug: Inserted main_create@6.ops[5]: 'store tmp%8#0 to l-stack (copy)' +debug: Replaced main_create@6.ops[7]: 'load tmp%8#0' with 'load tmp%8#0 from l-stack (no copy)' +debug: Found 3 edge set/s for examples.hello_world.arc4_contract.HelloWorldContract.approval_program +debug: Inserted say_hello_block@0.ops[6]: 'store tmp%1#0 to l-stack (copy)' +debug: Replaced say_hello_block@0.ops[8]: 'load tmp%1#0' with 'load tmp%1#0 from l-stack (no copy)' +debug: Inserted say_hello_block@0.ops[2]: 'store tmp%0#0 to l-stack (copy)' +debug: Replaced say_hello_block@0.ops[5]: 'load tmp%0#0' with 'load tmp%0#0 from l-stack (no copy)' +debug: Output IR to /examples/hello_world/out/contract_HelloWorldContract.ssa.ir +info: Optimizing examples.hello_world.contract.HelloWorldContract at level 1 +debug: Begin optimization pass 1/100 +debug: Optimizing subroutine examples.hello_world.contract.HelloWorldContract.approval_program +debug: Splitting parallel copies prior to optimization +debug: Optimizer: Arithmetic Simplification +debug: Optimizer: Constant Replacer +debug: Optimizer: Copy Propagation +debug: Optimizer: Intrinsic Simplifier +debug: Optimizer: Remove Unused Variables +debug: Optimizer: Simplify Conditional Branches +debug: Optimizer: Remove Linear Jump +debug: Optimizer: Remove Empty Blocks +debug: Optimizer: Remove Unreachable Blocks +debug: Optimizing subroutine examples.hello_world.contract.HelloWorldContract.clear_state_program +debug: Splitting parallel copies prior to optimization +debug: Optimizer: Arithmetic Simplification +debug: Optimizer: Constant Replacer +debug: Optimizer: Copy Propagation +debug: Optimizer: Intrinsic Simplifier +debug: Optimizer: Remove Unused Variables +debug: Optimizer: Simplify Conditional Branches +debug: Optimizer: Remove Linear Jump +debug: Optimizer: Remove Empty Blocks +debug: Optimizer: Remove Unreachable Blocks +debug: No optimizations performed in pass 1, ending loop +debug: Output IR to /examples/hello_world/out/contract_HelloWorldContract.cssa.ir +debug: Removing Phis from examples.hello_world.contract.HelloWorldContract.approval_program +debug: Removing Phis from examples.hello_world.contract.HelloWorldContract.clear_state_program +debug: Output IR to /examples/hello_world/out/contract_HelloWorldContract.post_ssa.ir +debug: Sequentializing parallel copies in examples.hello_world.contract.HelloWorldContract.approval_program +debug: Sequentializing parallel copies in examples.hello_world.contract.HelloWorldContract.clear_state_program +debug: Output IR to /examples/hello_world/out/contract_HelloWorldContract.parallel_copies.ir +debug: Coalescing local variables in examples.hello_world.contract.HelloWorldContract.approval_program using strategy RootOperandGrouping +debug: Coalescing resulted in 0 replacement/s +debug: Coalescing local variables in examples.hello_world.contract.HelloWorldContract.clear_state_program using strategy RootOperandGrouping +debug: Coalescing resulted in 0 replacement/s +debug: Output IR to /examples/hello_world/out/contract_HelloWorldContract.final.ir +debug: Inserted main_block@0.ops[5]: 'store tmp%0#0 to l-stack (copy)' +debug: Replaced main_block@0.ops[7]: 'load tmp%0#0' with 'load tmp%0#0 from l-stack (no copy)' +debug: Inserted main_block@0.ops[1]: 'store name#0 to l-stack (copy)' +debug: Replaced main_block@0.ops[4]: 'load name#0' with 'load name#0 from l-stack (no copy)' +info: Writing hello_world/out/arc4_contract.approval.teal +info: Writing hello_world/out/arc4_contract.approval.debug.teal +info: Writing hello_world/out/arc4_contract.clear.teal +info: Writing hello_world/out/arc4_contract.clear.debug.teal +info: Writing hello_world/out/contract.approval.teal +info: Writing hello_world/out/contract.approval.debug.teal +info: Writing hello_world/out/contract.clear.teal +info: Writing hello_world/out/contract.clear.debug.teal +info: Writing hello_world/out/application.json +>> exit code = 0 \ No newline at end of file diff --git a/examples/sizes.txt b/examples/sizes.txt index 2f024b4889..686c7a04ec 100644 --- a/examples/sizes.txt +++ b/examples/sizes.txt @@ -26,6 +26,8 @@ contains 155 156 edverify 33 33 enumeration 536 507 everything 424 421 +hello_world 18 18 +hello_world/arc4_contract 85 74 koopman 12 5 less_simple 93 87 local_storage/local_storage_contract 317 314