Skip to main content

A Framework for building PyTeal Applications

Project description

Beaker

Beaker is a smart contract development framework for PyTeal.

 

 

 

Hello, Beaker

from pyteal import *
from beaker import *


hello_app = Application("HelloBeaker")


@hello_app.external
def hello(name: abi.String, *, output: abi.String) -> Expr:
    # 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(),
    # Pass instance of app to client
    app=hello_app,
    # 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(hello, name="Beaker")
print(result.return_value)  # "Hello, Beaker"

Install

Beaker requires Python >= 3.10

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 network running to compile and test contracts.

Install AlgoKit

and start it

$ algokit localnet start
$ algokit localnet status

Front End

See Beaker TS to generate a front end client for a Beaker App.

Testing

You can run tests from the root of the project using pytest

Use

Examples

Docs

Please report bugs and get any contracts audited

We recommend that any production smart contracts be audited by a professional before deployment. Beaker has been thoroughly tested, but we cannot guarantee that it is entirely free of bugs.

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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

beaker_pyteal-1.1.1-py3-none-any.whl (47.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page