# algoDEA - Algorand IntelliJ Plugin

![](/files/-MLBkFSzDK00rRwWw5vn)

> "algoDEA" provides end to end development life-cycle on Algorand blockchain using IntelliJ IDE. Using this plugin, developers can create and test both stateless and stateful smart contracts directly from their IntelliJ IDE. It also provides other features like ASA management, Transactions, Test account management etc.

**GitHub :** <https://github.com/bloxbean/algodea>

### Getting started with AlgoDEA

{% embed url="<https://youtu.be/sah1z0BinW0>" %}


# Overview

## algoDEA

"algoDEA"  provides end to end development lifecycle on Algorand blockchain using IntelliJ IDE. Using this plugin, developer can create and test both stateless and stateful smart contract directly from their IntelliJ IDE. It also provides support for ASA creation, management and transfer.

The account management module in the plugin provides a simple way for the developers to manage their test accounts in one place.

The plugin is currently available in JetBrains Official Plugin Repository <https://plugins.jetbrains.com/plugin/15300-algodea-algorand-integration>

The latest plugin binary can be also downloaded from <https://github.com/bloxbean/algodea/releases>

**Git Repository :** <https://github.com/bloxbean/algodea>

The followings are the list of features currently supported by the plugin.

#### **Features**

* Algorand Smart Contract Project type
* Code Completion, Syntax Highlighter and other editor level support for TEAL file
* Create Stateless & Stateful Smart Contract
* Algorand Node support
  * Custom node
  * Purestake.io
* TEAL Compile using "goal" and algod REST api endpoint&#x20;
* Account Management
  * Create account
  * Create Multi-Sig account
  * List Account
  * Account Details
  * Dump Account
* Stateless Smart Contract
  * Generate Logic sig and multi-sig Logic Sig&#x20;
  * Send Logic Sig transactions
* Stateful Smart Contract&#x20;
  * Create Application
  * Call, OptIn, CloseOut, Clear, ReadState
  * Delete Application
  * Update Application
* Asset Management
  * Creat, Modify, OptIn, Freeze, UnFreeze, Revoke, Destroy
* Transfer
  * Algo, ASA
* Atomic Transfer
* TEAL Debugger
* PyTEAL support


# Installation using JetBrains Plugin Repository

The algoDEA Algorand Integration plugin is available on JetBrain's official plugin repository. You can install this plugin directly from your IntelliJ IDE.

### Supported IntelliJ version  (2020.2 and above)

* IntelliJ IDEA Community / Ultimate / Educational
* PyCharm
* GoLand
* WebStorm
* PhpStorm

### Installation

1. Go to Configure > Plugins

![](/files/-MLBVE2DtiEuw_PVznF8)

* Search marketplace with "Algorand" or "algodea".

![](/files/-MLBVSZ397_MIe5ILunJ)

* Click Install

![](/files/-MLBVYscmwN5mkJymBzS)

* Restart&#x20;

### Video

{% embed url="<https://youtu.be/wT6ZEYBYn5w>" %}


# Installation - Manual

## Download algoDEA plugin binary

Download the latest version of algoDEA plugin zip file from [ https://github.com/bloxbean/algodea/releases](https://github.com/bloxbean/algodea/releases)

### Supported IntelliJ version  (2020.2 and above)

* IntelliJ IDEA Community
* IntelliJ IDEA Ultimate
* IntelliJ IDEA Educational

### Installation

* Start IntelliJ IDEA (2020.2 and above)
* Select Configure > Plugins

![](/files/-ML0vciz6HVpRfWZIQKx)

* Select "Install Plugin from Disk..."

![](/files/-ML0vK1NEXJaV0loHZlu)

* Click "Restart IDE" to restart and install the plugin

![](/files/-ML0v_2-2RLdi937Juod)

### Video

{% embed url="<https://youtu.be/jjhEu-gjjhE>" %}


# Algorand Node Configuration

Currently you can configure both a custom Algorand  or Purestake.io node in the IDE. Once configured, you can use the configured node to compile or deploy TEAL program and perform other opertations.

*TEAL compilation using a Local SDK("goal" command line tool) is currently supported on MacOS and Linux. For Windows, you can use a running Algorand Node for compilation.*

### Video

{% embed url="<https://youtu.be/iwx0j4DqzgU>" %}


# Account Management

The following account management features are supported

* Create account
* Create multi-sig account
* List accounts
* Show account details (Balance, Apps, Assets etc.)
* Import an account from mnemonic
* Import a read-only account (No mnemonic)

Account management features are accessible from Algorand > Accounts menu.

### Video

{% embed url="<https://youtu.be/RQvjSM-4Ztw>" %}


# Algorand Project Structure

The Algorand project's standard directory layout :

![](/files/-MSmIWfy25b-v3Z9jLVC)

| Directory / File      | Description                                                                                                                                                                                                                                                                                                                       |
| --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **src**               | TEAL program files                                                                                                                                                                                                                                                                                                                |
| **algo-package.json** | Algorand package json files. Every algorand project should have this file at top level.                                                                                                                                                                                                                                           |
| **generated-src**     | Any generated source files from original TEAL programs are stored here. Example: If a TEAL program uses variables (VAR\_TMPL\_\*) inside the source code, the plugin generates the final source files with variable values under this folder. Also, the TEAL file generated during PyTeal compilation is  created in this folder. |
| **build**             | Build folder. The compiled binaries and other files generated from source are stored here.                                                                                                                                                                                                                                        |
| **build/toks**        | Compiled TEAL file                                                                                                                                                                                                                                                                                                                |
| **build/lsigs**       | Logic Sig files generated from TEAL program                                                                                                                                                                                                                                                                                       |
| **build/txns**        | Exported transaction files                                                                                                                                                                                                                                                                                                        |
| **build/dryrun**      | Dry Run output files                                                                                                                                                                                                                                                                                                              |


# Compile TEAL Program

A TEAL program can be compiled using goal command line tool or an Algorand node.

*TEAL compilation using a Local SDK ("goal" command line tool) is currently supported on MacOS and Linux. For Windows, you can use a running Algorand Node for compilation.*

1. Configure compiler.  Right click on the project / editor > Algorand > Configuration

You can configure a Local SDK (goal) or an Algorand node for the compilation. To do so, go to the configuration settings UI and update compiler setting.

![](/files/-MLCC8NuNsSIikQlgmuE)

![Compile using goal](/files/-MLCCDkslGzPYMmCE2_-)

![Compile using Purestake node](/files/-MLCCHtFEb3sbeui1e0x)

2\.  To compile, right click > Compile TEAL

![](/files/-MLCCatWDy196wMulo93)

3\. Alternatively, you can also configure compiler setting in the **"AlgorandExplorer"** toolwindow tab.

![](/files/-MLCClgMPcsK1rxcpN5J)

### Video - How to compile a TEAL program

{% embed url="<https://youtu.be/EEL0Xair7_g>" %}


# Import an existing project

You can also create a project by importing existing source.&#x20;

The plugin checks if "algo-package.json" file is available at the project root or not and accordingly it enables or disables "Algorand" function.

1. Create a file "**algo-package.json**" in the project root folder with the following content.

```
{
  "name": "<project_name>",
  "version": "<version>"
}
```

&#x20;    **Note:** Replace \<project\_name> and \<version> with actual values.&#x20;

2\. To import the source, click on File > New > Project From Existing Source.

![](/files/-MLC0SOD-3BqOlcJv34t)

3\. Select the existing source root folder. Click next.

![](/files/-MLC1n3FGVHAv19i6Kfl)

![](/files/-MLC1r0yPEu6bioY5yVO)

![](/files/-MLC1uFKtVKmZt8qnPpE)

4\. Now you should see, "Algorand" menu option in the project popup menu. If you don't see the menu item, wait for sometime or restart the IDE.

![](/files/-MLC2Efvzb2ctaaHrZZC)


# Variables/Placeholders in TEAL program

You can define variables or placeholders in your TEAL program. During compilation, the IDE will ask to input values for these variables.

The variable name should always start with a prefix **VAR\_TMPL\_ .**&#x20;

**Example:**

```
#pragma version 2

int VAR_TMPL_AMOUNT
txn Amount
...
...
```

In the above example,  when you compile the TEAL program, you need to enter VAR\_TMPL\_AMOUNT variable value. The IDE automatically detects all variables start with VAR\_TMPL\_ and asks the user for the variable values if required. The IDE then creates the final source file in build/generated\_src folder and then compile the final source file using the configured compiler (goal or Algorand node).


# Create Project - Stateful Smart Contract

### Video

{% embed url="<https://youtu.be/ud-voY0BT5Y>" %}
Create a Stateful Contract Project in IntelliJ IDEA
{% endembed %}

{% embed url="<https://www.youtube.com/watch?v=N1q6BNvWCWQ>" %}
Create a Stateful Contract Project in PyCharm
{% endembed %}


# Stateful Smart Contract - Deploy

### Video

{% embed url="<https://youtu.be/jLLMu5T8XhE>" %}


# Multiple Stateful Smart Contract in a Project

### Video

{% embed url="<https://www.youtube.com/watch?v=f2IR0VHHkjQ>" %}


# Create Project - Stateless Smart Contract

### Video

{% embed url="<https://youtu.be/KBOm5fPEfrI>" %}


# Stateless Smart Contract - Delegated Signature

### Video

{% embed url="<https://youtu.be/4S6nTqp_GCA>" %}


# Stateless Smart Contract - Contract Account

### Video

{% embed url="<https://youtu.be/X-bWzpkEqLA>" %}


# Create, Manage & Transfer

### Video

{% embed url="<https://youtu.be/j3U5mKd5uHc>" %}


# Create Atomic Transfer

You can create  an **Atomic Transfer** transaction directly inside IntelliJ IDE. Multiple transactions can be grouped inside a single Atomic Transfer transaction, so that either all succeed or all fail.

To create an Atomic Transfer, you need to first export each individual transaction as json file. Once all required transactions are exported to their corresponding json files, you can group them and create an Atomic Transfer transaction in the "Atomic Transfer" option in the IDE.

The following sections describe how to export transactions,  create & post Atomic Transfer transactions.

1. **Export Transaction**

You can export any type of transaction ( Payment, Stateless contract, Stateful contract) to a json file through **"Export Tx"** button in the transaction screen. When export button is click, transaction is not posted to the network.

![](/files/-MNcyEoLPye9fh_7okNb)

![](/files/-MNd3RXXXJJyURDn2QXs)

\
Transaction json files are generated under the build/txns folder.

![](/files/-MNczj2fKQjBEAjEtQsH)

#### 2. Choose Atomic Transfer

To create an Atomic Transfer transaction, select Algorand > Atomic Transfer

![](/files/-MNd088d9tpjT0gbdh2P)

#### 3. Select Individual Transactions

Select and add individual transactions.

![](/files/-MNd0o8z_Sc_gc1BQOOp)

#### 4. Create Group

After adding all individual transactions, click on **"Create Group"** to create and assign group id to each transaction in the group. Once the group id is assigned, "Create Group" button will be disabled.

![](/files/-MNd1rAhekOyb868rX6B)

#### 5. Sign each transaction separately

Right click on each transaction and select "Sign" option to sign that transaction.

![](/files/-MNd1vk1b87OneEtPGN0)

![](/files/-MNd1yX886k8_6MsO1XC)

#### 6. Post Atomic Transfer transaction

Once all the transactions are signed, you are ready to post the atomic transfer transaction. Click Ok to post the atomic transfer transaction.

![](/files/-MNd2PdPmUUox66u--jr)

Now either all transaction succeed or all fail.


# Dry Run Stateful / Stateless Contract Call

Smart contracts can be debugged using two different methods.&#x20;

The first is an interactive debugger that uses the `tealdbg` command-line tool to launch a debug session where the smart contract can be examined as the contract is being evaluated.&#x20;

The second method is "Dry Run" which outputs a line by line result of the evaluation of the smart contract.&#x20;

With Dry Run support in algoDEA plugin, you can "Dry Run" any stateful or stateless smart contract transaction. You can also "Dry Run" an Atomic Transfer with multiple stateless and stateful smart contract transactions.

For stateful contract dry run, you also need to provide the path to the source file.

All contract transaction UIs (stateful contract, stateless  contract/ logic sig, Atomic Transfer) have a "Dry Run" button.&#x20;

![Dry Run - Stateful Contract Call Transaction](/files/-MNfXIZsNV4ygRawVxoF)

&#x20;

![Dry Run - Logic Sig Txn](/files/-MNfYXlqpC16eZNaewk2)

#### Dry Run - Stateful Smart Contract Transaction&#x20;

While you try to dry run a stateful contract transaction, IDE opens an UI to capture additional inputs required for the dry run call. Some of the inputs like application Id, txn index are auto-populated. For a stateful contract call, you need to select the source teal file.

![Dry Run - Input screen](/files/-MNfdrMBzrmKQ_Vcd1Eb)

#### Dry Run Output file

Dry run output files are generated and stored under **build/dryrun** folder.

![](/files/-MNff9LgAIIoWZ3gWcyK)

![Dry Run - Result file content](/files/-MNffaWTKf7RTmor2Kt2)


# Dry Run - Atomic Transfer

You can also use the "Dry Run" functionality for a group of transactions which are part of an Atomic Transfer.

Once you have created an Atomic Transfer by selecting individual transactions, grouping and signing in Atomic Transfer UI, you can provide additional Dry Run Context information for each transaction by \
Right click > DryRun Source.

![](/files/-MNfn-4k5lud80QEtnv7)

![](/files/-MNfn4D4xIVw9ayfXuYp)

![](/files/-MNfnRNejwVCq-JovAuU)


# Configure Python SDK and PyTeal

To use PyTeal in your smart contract project, you need to make sure the following steps are done.

### 1. Install Python plugin in IntelliJ IDE

If you don't have Python plugin installed yet, you can do that from "Plugins" page in IntelliJ IDE.

For **IntelliJ IDEA Community Edition**, you need to install "Python Community Edition" plugin.

![](/files/-MNfziRikq8w757KwXCy)

For **IntelliJ IDEA Ultimate Edition**, check for "Python" plugin

![](/files/-MNg0ukQoMLE2D8-OECJ)

### 2. Configure / Add Python SDK and Install PyTeal

Once the python plugin is installed, you can create a Python SDK inside IntelliJ IDE. But before that,  you need to make sure you already have Python installed on your machine.

#### To create / configure a new Python SDK&#x20;

* Right click on the  project and select "Open Module Settings"

![](/files/-MNg1jUMhf8p-yMB-wJB)

* Select "SDKs" and Click "+" to add a new Python SDK

&#x20;   &#x20;

![](/files/-MNg2WWosedy0kUFQ5OO)

#### Install PyTeal

* Once the Python SDK is there, go to "packages" tab and click "+" to install pyteal.

![](/files/-MNg35WMp-NfR7wLeL9U)

### 3. Select Python SDK as Project's SDK

Go to "Project" and select Python SDK.

![](/files/-MNg3KV5g2fJA7WBfrs7)

Now you are ready to write your first PyTeal program.


# Create PyTeal file

#### To create a new PyTeal file,

* Right Click on source folder > New > PyTeal File

![](/files/-MNg6mEMpBq-xbAom5Z7)


# Create or Configure a Stateful Contract with PyTeal Programs

You can create a new stateful contract configuration and set a PyTeal program as approval or clear state program for the stateful application.

To create a new stateful contract configuration,

* Right click on the project > New > Stateful TEAL Configuration

![](/files/-MNg7ZbDGih6i6dGGeJa)

* Provide contract name, approval program and clear state program

![](/files/-MNgJGQgi5AeKIzbLvJC)

* Select PyTeal program for both approval and clearstate program

![](/files/-MNgJR9U7Hhz61mLuIaY)

* Notice that when you select a .py file for approval / clear state program, the value will be converted to \*.teal file in the generated-src folder. That's because the pyteal file is compiled into TEAL file during pyteal compilation.

![](/files/-MNgJgd4J5nlpYkL4tPC)


# Compile PyTeal File

You can not directly deploy a PyTeal file to create a stateful app or stateless logic sig file. The PyTeal file first needs to be compiled into a regular TEAL file and then the generated TEAL file can be used as part of stateful app or logic sig.

* To compile a PyTeal file, right click on the pyTeal file and select "Compile PyTeal".

![](/files/-MNgLE5z87Qjc6RFUYit)

* After PyTeal compilation, the final TEAL file is generated under **generated-src** folder.<br>

![](/files/-MNgL_KAQV5RSKltkCKo)

* Now you can use this generated TEAL file as a regular TEAL file.&#x20;

&#x20;For example:  Create a Logic Sig from this generated TEAL file or create a stateful app.

![](/files/-MNgM2WxnocJVtTw3aDL)


# Overview

**Supported Since : 0.7.0-Beta1**

The plugin provides integration with "tealdbg" to provide debugging support for TEAL smart contracts. Currently, the debugger support is available for the followings:

* Stateless Smart Contract
* Stateful Smart Contract
* Atomic Transfer

When debugger option is chosen for a smart contract transaction, the following steps are done by the plugin :-

* If stateful smart contract, it creates the debugger context (Dry run dump) file
* Starts tealdbg with TEAL source file and dry run dump file
* Finds Google Chrome installation and automatically opens the browser for debugging (If automatic detection is enabled)

Alternatively, developer can directly use the dry run dump file and debug. The steps are as follows :-

* Create debugger context (dry run dump) file from the supported transaction UI
* Right click on the dry run dump file and select "Start TEAL debugger" to start the debugger.

**Note:** IDE automatically finds the Chrome executable and opens it. But this feature has only been tested on **Mac OS** and **Windows**. For **Linux**, you may need to configure the Chrome executable path in the "Debugger Configuration" UI.


# Debugger Configuration

### Prerequisites

* Install Google Chrome Browser
* Install Algorand Node binary and configure "Local SDK"
* Select Local SDK as  "Compilation Target"&#x20;

### Configuration

The debugger configuration UI can be accessed from the Algorand tab in the right side panel of the IDE.

![](/files/-Miargs44o82iQj2ejc9)

### Stop Debugger Process

When the debugger is running, you should see a "Stop" button in the toolbar in Algorand tab.

![](/files/-MiatpWy-MjHCJnsGMC_)


# Debug Stateless Contract

To debug a stateless contract :-

* Open stateless teal file in the editor
* Right click and select  "Algorand >  Stateless Contract > Send Transaction (TEAL File)"

![](/files/-MiayP8cmAbBs-ldzuHb)

* Enter transaction info and click "Debug"

![](/files/-MiazFe-u78TC-WGJ0cv)

* The IDE  starts tealdbg process and opens the Chrome browser (If automatic browser opening option is not disabled)


# Debug Stateful Smart Contract

To debug a stateful smart contract :-

* Right click on the editor and select "Algorand > Stateful Contract > Call App"
* Enter transaction details and click debug
* Enter debugger context info (Dry Run Context) like source teal file, accounts etc.&#x20;
* IDE automatically starts tealdbg with the required data and then opens Chrome browser for debugging (If automatic browser opening option is not disabled)

{% embed url="<https://youtu.be/YxF1krhD3AQ>" %}


# Debug Stateful Contract using Dry Run Dump file

You can also debug a stateful smart contract directly using a dry run dump file. Once the dry run dump file is exported, you can start debugger several times using the same dump file.&#x20;

* In Stateful Contract transaction UI, enter all the details
* Export dry run dump by selecting "Dry Run Dump" option
* Find dry run dump file under  build/dryrun
* Right click on the dry run dump file and select "Start TEAL Debugger"
* Dry run dump file's extension is ".dr.json"

{% embed url="<https://youtu.be/-L4iUu9LN3U>" %}


# Debug Atomic Transfer

* To debug an atomic transfer, you need to first export individual transactions using corresponding transactions UIs.
* If atomic transfer has a stateless contract, you need to also create a lsig file which will be later used during transaction signing.
* Make sure to select source file for each smart contract transaction through "Dry Run Source" option in Atomic Transfer UI.

The following video shows how to debug an atomic transfer with a stateful contract and stateless contract.

{% embed url="<https://youtu.be/KwL8pHrwtyo>" %}


# Debug Atomic Transfer using Dry Run Dump file

Similar to Stateful Contract debug, a dry run dump file can be exported in the atomic transfer UI. You can then use the dry run dump file to debug the contract.

* Right click on a dry run dump file (which can be found under build/dryrun) and select "Start TEAL Debugger" option

{% embed url="<https://youtu.be/yQQj-KpfTiY>" %}


