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 *
from beaker import *
# 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()))
# Create an Application client
app_client = client.ApplicationClient(
# Get sandbox algod client
client=sandbox.get_algod_client(),
# Instantiate app, pass it to client
app=HelloBeaker(),
# Get acct from sandbox and pass the signer
signer=sandbox.get_accounts().pop().signer,
)
# Deploy the app on-chain
app_id, app_addr, txid = app_client.create()
print(
f"""Deployed app in txid {txid}
App ID: {app_id}
Address: {app_addr}
"""
)
# Call the `hello` method
result = app_client.call(HelloBeaker.hello, name="Beaker")
print(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
Dev Environment
Requires a local sandbox.
NOTE: Currently requires a sandbox running with the source
config (or any config that contains this commit)
$ git clone git@github.com:algorand/sandbox.git
$ cd sandbox
$ sandbox up source
Testing
You can run tests from the root of the project using pytest
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
Hashes for beaker-pyteal-0.0.11.dev0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9362faf6f44cfadde4add16bbf0bbb9b9e0afc2bd13474ed6224faaa8bf43045 |
|
MD5 | aea0b5b154c5116dce0f7944b1fef4d9 |
|
BLAKE2b-256 | e632a9cfd2213d1e89f47c5290a18156275a973e8bef498c933b21aa7bb23776 |
Hashes for beaker_pyteal-0.0.11.dev0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 19096035a5a88891fd7397cb83e2ab4dcdab122a295c866e573e904549eb020e |
|
MD5 | 3baa856a35f871f6c7d0d9c4785127e6 |
|
BLAKE2b-256 | f571c1b52f78d1cb52891df2a16300a9611a2566bce6de226fc4ea81e8c5d39c |