Skip to content

A framework for writing Smart Contracts on Algorand

License

Notifications You must be signed in to change notification settings

daniel-makerx/beaker

Repository files navigation

Beaker

Beaker is a smart contract development framework for PyTeal.

With Beaker, we build a class that represents our entire application including state and routing.

 

 

WARNING

⚠️ Mostly Untested - Expect Breaking Changes ⚠️

Please file issues or prs and get any contracts audited

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 with the program version (default is MAX_TEAL_VERSION)
    app=HelloBeaker(version=6),
    # 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 beta config (or any config that contains this commit)

$ git clone [email protected]:algorand/sandbox.git
$ cd sandbox
$ sandbox up source

Testing

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

Use

Examples

Docs

Please feel free to file issues/prs

About

A framework for writing Smart Contracts on Algorand

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 99.9%
  • Shell 0.1%