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.
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
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
Next, clone this repository and cd to the root directory.
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
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.
python3 interact.py
This will deploy and interact with the calculator app.
Go into the calculator-beaker directory and run:
python3 calculator.py
This will compile, deploy, and interact with the calculator app.