How do I compile and execute a teal code in python without using goal?
You can use pyteal to create the TEAL or handwrite it. To use with the SDKs look at:
Additionally a new endpoint will be available very shortly. This endpoint will allow compiling TEAL directly. from the SDKs.
I can’t wait to use it. It’s tough trying to compile teal without goal. I’m done writing the pyteal codes but compiling to use within a transaction is my headache right now.
Actually, the REST API is available … and as @jsaonw says the SDKs will support this very shortly. https://github.com/algorand/go-algorand/tree/master/daemon/algod/api
ok great. but I need a help right now.
DISCLAIMER: This is an advanced response and includes limited documentation or lacks an example describing usage. A tutorial will be released in the coming weeks describing how to use this feature in detail.
@ddev I think you got this Currently the
master branch of
go-algorand contains the REST API
/v2/teal/compile which does exactly what you want. You POST your TEAL source code and it returns the program bytes and the contract address. We don’t yet have documentation posted, nor a tutorial to guide you through it use, so try this:
- First, you must enable the Developer API on your local
algodnode. Locate the “config.json” file within the data directory for your local node.
- Add the following json:
- Restart your
algodnode so it reads this new configuration value
- Use the following REST API excerpt to learn how to POST your data and the expected response:
Compile TEAL source code to binary, produce its hash
Given TEAL source code in plain text, return base64 encoded program bytes and base32 SHA512_256 hash of program bytes (Address style).
|TEAL source code to be compiled||string (binary)|
|200||Teal compile Result||Response 200|
|400||Bad Request - Teal Compile Error||ErrorResponse|
|401||Invalid API Token||ErrorResponse|
|default||Unknown Error||No Content|
|base32 SHA512_256 of program bytes (Address style)||string|
|base64 encoded program bytes||string|
oh great. That gives what I expect. Now I understand how the opcodes is converted. I’m gonna try compiling it from the editor cos I can’t access a node right now. Thanks again RyanRfox.
You can also use https://algodesk.io/teal/ to quickly compile TEAL smart contracts.
Cool. I’ll do just that now. Thank you.