/pyteal-milestone-dapp

Milestone based decentralized application on algorand blockchain network using pyteal for smart contracts

Primary LanguagePythonMIT LicenseMIT

Pyteal Milestone Dapp

NOTE: This code is not audited and should not be used in production environment.

NOTE: This tutorial is not for beginners and assumes the reader is familiar with setting up a private algorand node and setting up testnet accounts.

Resources

Link to Tutorial Read about algorand sandbox

This tutorial also touches on using algorand sandbox and setting account

Goal of Project and Concepts Covered.

  1. To teach about transacion fee pooling on algorand.
  2. Inner Transactions.
  3. Handling Errors when interacting with smart contract via a python script.

Set Up Environment

Docker Compose MUST be installed. Instructions.

On a Windows machine, Docker Desktop comes with the necessary tools. Please see the Windows section in getting started for more details.

Warning: Algorand Sandbox is not meant for production environments and should not be used to store secure Algorand keys. Updates may reset all the data and keys that are stored.

Usage

Use the sandbox command to interact with the Algorand Sandbox.

sandbox commands:
  up    [config]  -> start the sandbox environment.
  down            -> tear down the sandbox environment.

Sandbox creates the following API endpoints:

  • algod:
    • address: http://localhost:4001
    • token: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  • kmd:
    • address: http://localhost:4002
    • token: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  • indexer:
    • address: http://localhost:8980

Getting Started

Ubuntu and macOS

Make sure the docker daemon is running and docker-compose is installed.

Open a terminal and run:

git clone https://github.com/algorand/sandbox.git

In whatever local directory the sandbox should reside. Then:

cd sandbox
./sandbox up

It should run the released version of sandbox

This will run the sandbox shell script with the default configuration. See the Basic Configuration for other options.

Dependencies

Install all project dependencies

Open a terminal and run:

 python3 pip -r requirements.txt

Set Environment Variables

create a .env file in the root of the project and paste your environment variables as described in the .env.example file.

Set Testnet Account

import 3 testnet accounts to the goal app by running this command:

./sandbox goal account import

Fund Imported Testnet Account

./sandbox goal clerk send -a {amount} -f {provided accounts in goal} -t {imported accounts}

For more information on how to use alglorand sandbox visit:

sandox

Run the App

Open a terminal in project directory and run

cd src
python3 deploy.py