What's the best way to learn about Algorand?
Overview
This blog post gives developers an overview of the easiest way to get started with learning about the Algorand blockchain, its layer 1 capabilities, and smart contract development. I will discuss my journey, point you to interesting resources, and provide you with the most optimal path to become a capable Algorand developer.
In the beginning, Algorand development felt quite overwhelming for me. First, I had to understand its features, learn about the differences between the kmd, indexer, and algod client, understand how to use one of the SDKs, and learn about smart contract development. Let’s take a step back and analyze the best path to learn more about Algorand development.
Step 1: Understand Algorand’s Key Properties
I believe you should understand Algorand’s fundamental properties to make the correct choice to implement a blockchain solution. Algorand offers block finality after a single block, a high transaction throughput of more than 1000 transactions per second, and low fees (0.001 Algo). These properties make Algorand an excellent choice for decentralized applications that require fast transaction confirmation, require high throughput, and don’t want to spend tons of money on transaction fees.
Knowing this information will help you make a better decision when picking a blockchain platform for your use case. That being said, the above properties are attractive for almost all use cases.
Step 2: Learn About Algorand’s Layer 1 Capabilities
As a next step, you want to learn about Algorand’s layer 1 capabilities. It’s like learning about its selling points. These capabilities will help you get a deeper understanding of how to construct the solution you want to build. A short overview with related resources:
-
Atomic transfers: They allow you to bundle transactions and execute them as a group. If one of the transactions in your group fails, the others will also fail. This is very useful for escrow-related services, which are a typical design pattern among blockchain applications because of the lack of centralized services.
-
Algorand Standard Assets or ASAs: You can quickly create a new asset on-chain and derive the key properties from Algroand’s blockchain. This is very powerful because you can tokenize almost anything and trade it with the same speed and low cost as Algo tokens. For instance, the gaming industry can use ASAs to create non-fungible tokens (NFTs) for each in-game item. You can create an NFT by setting the supply to a single token. For more info, you can read an older tutorial by Jason Weathersby or look at the updated documentation for NFTs.
-
Multisignature accounts: Most people are familiar with multisig accounts. A quick explanation from the docs: “When the sender of a transaction is the address of a multisignature account, then authorization requires a subset of signatures, equal to or greater than the threshold value, from the associated private keys of the addresses that multisignature account is composed of.”
-
Smart contracts: Smart contracts used to be referred to as stateful contracts, so you still might find some references to that. A smart contract is a program written in TEAL that contains business logic. Only smart contracts can hold global storage. That means you can store values in the state of these contracts. On top of that, there’s also local storage that allows smart contracts to store values on a per-user basis. For instance, a lottery smart contract stores the total jackpot in the global storage while storing the gambled amount per user in the local storage.
-
Smart signatures: Smart signatures used to be referred to as stateless contracts, but they are actually used for signature delegation. The logic of a smart signature is stored on the blockchain, but you can’t call them. For each smart signature, you can generate an address and fund it with Algos or ASAs. Whenever an account successfully executes the logic of the smart signature, the funds are released from the account. It’s comparable to escrow functionality but with more fine-grained controls on spending the value within the account.
Step 3: Working with the indexer and algod client via SDK or API
Each Algorand node exposes an indexer and algod client to which you can connect. Actually, they also expose a kmd client that you can use to generate new wallets and manage accounts via a CLI tool like goal.
The indexer client is used to retrieve data from the blockchain, like transactions, blocks, or account data. In contrast, the algod client can be used to write data to the blockchain, by sending a transaction like a payment transaction or application call.
You have two options to interact with these APIs:
Option 1) Use an SDK in your programming language that hides the underlying API calls and makes it easier to interact with the above clients. For instance, the indexer exposes many filters that you can easily apply to a request. You can find indexer examples per language in the algorand/docs GitHub repository.
let transactionInfo = await indexerClient
.searchForTransactions()
.currencyGreaterThan(10)
.limit(5)
.do();
Option 2) Directly interact with the API. To send transactions to the blockchain, it’s easier to use an SDK. However, to quickly retrieve information, you can use the many GET endpoints the indexer exposes to look up information about transactions, balances, and applications. You can find all API references in the documentation. Here’s the indexer API reference.
This example shows how to retrieve block with ID 555
from the indexer.
curl "localhost:8980/v2/blocks/555" | json_pp
Step 4: Running an Algorand Node
We’ve just explored the key capabilities, layer 1 features, and exposed clients by the Algorand node. It’s time to prepare our development environment.
The easiest way to get started with Algorand development is to run your Algorand sandbox. This is a developer-focused version of the Algorand node software that you can run on your local machine. You can quickly set up new environments without having to sync with the testnet or mainnet. Therefore, this allows for rapid prototyping. You can watch a recent video in the Developer Office Hours on YouTube or read this tutorial.
Alternatively, you can use a service like Purestake who also runs nodes to which you can get access as a developer. However, this service comes with limitations on the number of requests you can send, and it’s a less flexible solution than the Algorand sandbox.
The documentation also explains how to run your Algorand node but this solution is not so flexible for development purposes.
Step 5: Algorand Smart Contracts and Smart Signatures
Smart contracts are the most essential feature of Algorand blockchain development. It allows developers to build complex decentralized applications. Before writing any smart contract, you have to pick your smart contract programming language of choice. If you’re looking for a great starter resource, take a look at the following Developer Office Hours series.
As a developer, you can choose between TEAL, PyTeal, and Reach. Among developers, PyTeal has been the most preferred language for smart contract development.
PyTeal is a wrapper language for TEAL and makes it easier for developers to write smart contracts. TEAL is a low-level language that can be compared to Assembly, where you directly interact with the stack. It’s much harder to learn but it gives you more finegrained-control over your code. On top of that, any PyTeal contract is compiled to TEAL. In order to check the validity of your contract, it’s still helpful to understand TEAL so you can verify or modify your TEAL smart contract.
Alternatively, you can also opt for Reach smart contract development. You can build DApps like a full-stack developer while focusing on business logic. The syntax itself looks very similar to the Javascript syntax.
5.1 Pick your smart contract language
Here’s a quick overview of when to pick which language.
PyTeal
- Allows for fast development
- Easier to learn, especially for Python developers
- Not easy to debug smart contracts because it uses TEAL
TEAL
- Ideal for more complex use cases
- Much slower to write TEAL code
- Steep learning curve
Reach
- Blockchain agnostic language that compiles to multiple chains
- Different paradigm to learn
- More accessible for JavaScript developers
In short, I prefer using PyTeal to write simple logic checks and compile them to TEAL. More advanced logic I prefer writing using TEAL because the language gives me more fine-grained control. On top of that, debugging a smart contract is essential to make sure everything works as expected. When debugging a smart contract, you will work with the compiled TEAL version of your PyTeal smart contract. For that reason, you should learn a bit of TEAL to understand what happens in the debugger. Here’s a great resource to get started with the TEAL debugger “tealdbg
”.
5.2 Smart Contract Programming Resources
PyTeal
- Use case: Build a Tic-Tac-Toe DApp
- Use case: Securities and permissioned tokens
- Use case: ASA Bidding application
TEAL
- Understanding the TEAL stack by example
- Using TEAL debugger to debug smart contract
Reach
- Development education series for Reach
- Using loop invariants for verification
Other Valuable Resources
What else is important when learning about Algorand blockchain development?
-
Algorand Parameters Table: This table details smart contract constraints, minimum balance for accounts, and minimum balance for smart contracts. It’s essential information that many developers miss when starting with smart contract development.
-
Transaction Fees: There are two fee modes you can use when sending transactions. Make sure to read up about the difference between the
suggested fee
andflat fee
modes. -
Connect web apps using AlgoSigner: This video tutorial shows how to connect web apps using AlgoSigner. It allows users to easily use Algorand-based Dapps from the web. You can also check out this tutorial.
-
How to add mobile signing support to your DApp with WalletConnect
Conclusion
Don’t underestimate the individual components involved with DApp development on Algorand. You have to learn to interact with the different clients, whether you use an SDK or the APIs directly. Further, you have to learn about the different key features, such as atomic transactions, multisignature accounts, Algorand Standard Assets, smart contracts, and smart signatures. To top it off, you should learn how to work with the AlgoSigner extension or use the WalletConnect protocol to integrate wallet functionality into your interface.