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
Built Distribution
Close
Hashes for beaker-pyteal-0.0.10.post1.dev0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | b85b6893db8defd673191a36ea797facfe4afbc5483c94d14323eac5f3d06115 |
|
MD5 | 04874b6678434dae65e92605dc3cc9aa |
|
BLAKE2b-256 | 40695a08ec00d932b7f45bee299ff4b7d72d53179b426a86ac4594188002be84 |
Close
Hashes for beaker_pyteal-0.0.10.post1.dev0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5894d3a3821c40f9d1468f9941c4ae02540ae074dd5d80f1c2c1a79781706fdb |
|
MD5 | b68bd249a6b521aa9687b6c74b5720f2 |
|
BLAKE2b-256 | 5a371199e65277141e416093fd4b26703618adb41415d0405f93a0a3d3dc5b82 |