A Framework for building PyTeal Applications
Project description
Beaker
Beaker is a smart contract development framework for PyTeal inspired by Flask
With Beaker, we build a class that represents our entire application including state and routing.
Mostly Untested - Expect Breaking Changes
Hello, Beaker
from pyteal import abi, Concat, Bytes
from beaker import Application, external
# Create a class, subclassing Application from beaker
class HelloBeaker(Application):
# Add an external method with ABI method signature `hello(string)string`
@external
def hello(self, name: abi.String, *, output: abi.String):
# Set output to the result of `Hello, `+name
return output.set(Concat(Bytes("Hello, "), name.get()))
if __name__ == "__main__":
from beaker import sandbox, client
# Instantiate our app
app = HelloBeaker()
# Get an acct from the sandbox
acct = sandbox.get_accounts().pop()
# Create an Application client
app_client = client.ApplicationClient(
client=sandbox.get_algod_client(), app=app, signer=acct.signer
)
# Deploy the app
app_id, app_addr, txid = app_client.create()
print(f"Deployed app with id {app_id} and address {app_addr} in txid {txid}")
# Call the `hello` method
result = app_client.call(app.hello, name="Beaker")
assert result.return_value == "Hello, Beaker"
Install
You can install from pip:
pip install beaker-pyteal
Or from github directly (no promises on stability):
pip install git+https://github.com/algorand-devrel/beaker
Use
Please feel free to file issues/prs
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
beaker-pyteal-0.0.10.dev0.tar.gz
(51.0 kB
view hashes)
Built Distribution
Close
Hashes for beaker-pyteal-0.0.10.dev0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd6fbb4d29e897e98e20bc603929b5a00b8bc3b2de6577f71ef501ff9e683408 |
|
MD5 | 64b8c7b93387c26f1e2b672a2a2baa98 |
|
BLAKE2b-256 | 2c363aa691d6d7915847f8a65252ed61f92a170a69661e5719c692c3a0e8502c |
Close
Hashes for beaker_pyteal-0.0.10.dev0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d75da39352f835f73406ab8560e0dc75a0e410b5afed54c5cc9b274f4a86934d |
|
MD5 | 25ac59f72013789c728bfa48cbd8e9c8 |
|
BLAKE2b-256 | ada2b63fa9570fee15a2ad1a3e392c036c3ce216257018a14987ddbf468989e8 |