Skip to content

Shows how beaker improves smart contract organization and interaction.

License

Notifications You must be signed in to change notification settings

tzaffi/beaker-calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Showcasing Beaker

This is a direct comparison of the simple calculator contract written in Beaker and bare PyTeal and it shows how Beaker simplifies writing smart contracts and interacting with them.

Contents

calculator-pyteal/ - Directory containing calculator app and interactions in bare PyTeal and Python SDK
approval.teal - autogenerated calculator TEAL approval program
clear.teal - autogenerated calculator TEAL clear program
contract.json - A JSON file describing the interface of the contract to be read by SDK clients
contract.py - A calculator PyTeal contract that generates a set of methods that can be called as ABI methods
interact.py - A set of interaction calls that uses the Python SDK to interact with the calculator app
sandbox.py - helper method that fetch accounts from sandbox

calculator-beaker/ - Directory containing calculator app and interactions in Beaker
calculator.py - A calculator Beaker contract and interaction calls with Beaker

Development Environment

Install Sandbox

Install the sandbox to start a local private node and start it with the source configuration.

NOTE: Currently Beaker requires a sandbox running with the source config (or any config that contains this commit)

If you're in the sandbox directory run:

./sandbox up source

Clone repository

Next, clone this repository and cd to the root directory.

Setup Virtual Environment

Create a virtual environment inside the project directory.

python3 -m venv venv

Activate virtual environment.

source ./venv/bin/activate

requirements.txt file contains all of the required dependencies and packages. Install them in your virtual environment by running:

pip install -r requirements.txt

Check all dependencies and packages install in your virtual environment by running:

pip list

Testing Calculator App with Bare PyTeal and Python SDK

Compile Contract

After double checking that sandbox is running, go into the calculator-pyteal directory and run:

python3 contract.py

This will create the teal source files in approval.teal and clear.teal, and contract.json ABI file.

Deploy and Interact

python3 interact.py 

This will deploy and interact with the calculator app.

Testing Calculator App with Beaker

Compile, Deploy, and Interact

Go into the calculator-beaker directory and run:

python3 calculator.py

This will compile, deploy, and interact with the calculator app.

About

Shows how beaker improves smart contract organization and interaction.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages