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.9.dev0.tar.gz
(50.5 kB
view hashes)
Built Distribution
Close
Hashes for beaker_pyteal-0.0.9.dev0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c93dc1750e58945da128849447bdc1b9ec32a21f9eb37e7b33666642f37a671b |
|
MD5 | 95f4e0049359d2703e5dbd8b4a90dfbc |
|
BLAKE2b-256 | 5a891aeee3f670d90173ded3d932fb6066e9476bef73a37f52741adf1eeb7527 |