Getting started overview

To begin developing on Algorand, developers typically embark on a sequence of steps that involve setting up a local or remote development environment, procuring an Algorand account, and establishing a connection to an Algorand node. This foundational setup allows for the submission of transactions, interaction with smart contracts written in TEAL (Transaction Execution Approval Language), and management of Algorand Standard Assets (ASAs).

Algorand offers a range of official SDKs for popular programming languages including Python, JavaScript, Go, and Java, designed to streamline interaction with the network. These SDKs abstract away direct REST API calls, enabling developers to integrate blockchain functionalities more efficiently into their applications. The Algorand developer portal provides comprehensive documentation, tutorials, and examples to guide this process, catering to both new and experienced blockchain developers Algorand developer documentation portal.

Here's a quick reference for the essential steps:

Step What to Do Where
1. Set up Environment Install an Algorand SDK (e.g., Python SDK) Local machine or development server
2. Create Account Generate a new Algorand wallet address and mnemonic phrase Algorand Sandbox or SDK utilities
3. Fund Account Obtain Algos for gas fees (testnet faucet) Algorand TestNet Dispenser
4. Configure Node Access Connect to a PureStake AlgoNode or deploy a local Algorand node Application code or Algorand Sandbox
5. Send First Transaction Construct and sign a simple Algo transfer transaction SDK example code

Create an account and get keys

An Algorand account is identified by a public address and controlled by a private key. The private key, often represented by a 25-word mnemonic phrase, is crucial for signing transactions and proving ownership of assets associated with the account. It is imperative to secure this mnemonic phrase, as loss means irreversible loss of funds and assets, and compromise means unauthorized access to your account.

For development and testing, Algorand provides a Sandbox environment, which is a Docker-based setup that includes a private Algorand network, an Algod (Algorand node daemon) instance, and a KMD (Key Management Daemon) for local account management. This is an ideal starting point for generating accounts without interacting with the mainnet or testnet directly Algorand Sandbox setup guide.

Using the Algorand Python SDK to create an account:

from algosdk import account, mnemonic

# Generate a new private key and address
private_key, address = account.generate_account()
print("Address:", address)

# Convert the private key to a mnemonic phrase
mn = mnemonic.from_private_key(private_key)
print("Mnemonic:", mn)

# IMPORTANT: Store your mnemonic securely. Do not share it.

This Python script will output an Algorand public address and its corresponding 25-word mnemonic phrase. For production environments, consider using secure key management solutions, such as hardware wallets or secure enclaves, rather than storing mnemonic phrases directly in code or plain text files.

After creating an account, you will need to fund it with some Algos to pay for transaction fees. On the Algorand TestNet, you can obtain free Algos using the Algorand TestNet Dispenser. Simply paste your newly generated public address into the dispenser to receive test Algos.

Your first request

To interact with the Algorand blockchain, your application needs to connect to an Algorand node. Nodes expose REST APIs (algod for general blockchain interaction and indexer for querying historical data) that allow you to submit transactions, query account information, and inspect blockchain state. For development, you can use a public node provider like PureStake's AlgoNode, or run a local node using the Algorand Sandbox.

This example demonstrates sending a simple Algo transfer transaction using the Algorand Python SDK. Before running, ensure your generated account has sufficient test Algos from the TestNet dispenser.

Prerequisites:

  • Python 3.x installed
  • Algorand Python SDK installed: pip install py-algorand-sdk
  • An Algorand account with test Algos
  • An Algorand node URL and token (e.g., from AlgoNode or local Sandbox)

Example: Sending Algos with Python SDK

from algosdk.v2client import algod
from algosdk import transaction, mnemonic

# --- Configuration --- #
algod_address = "YOUR_ALGOD_ADDRESS"  # e.g., "http://localhost:4001" for Sandbox or AlgoNode URL
algod_token = "YOUR_ALGOD_TOKEN"    # e.g., "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" for Sandbox or AlgoNode API Key

# Replace with your account's mnemonic and a recipient address
sender_mnemonic = "YOUR_25_WORD_MNEMONIC"
sender_private_key = mnemonic.to_private_key(sender_mnemonic)
sender_address = account.address_from_private_key(sender_private_key)

recipient_address = "RECIPIENT_ALGORAND_ADDRESS" # e.g., another account you control or a friend's
amount_to_send = 1000000  # 1 Algo = 1,000,000 microAlgos

# --- Connect to Algorand node --- #
algod_client = algod.AlgodClient(algod_token, algod_address)

# --- Build and sign transaction --- #
def send_algo_transaction():
    try:
        # Get network parameters for transaction construction
        params = algod_client.suggested_params()

        # Create a transaction
        unsigned_txn = transaction.PaymentTxn(
            sender_address,
            params,
            recipient_address,
            amount_to_send,
            None,  # Close remainder to
            "First Algo transfer from apispine"
        )

        # Sign the transaction with the sender's private key
        signed_txn = unsigned_txn.sign(sender_private_key)

        # Send the transaction to the network
        txid = algod_client.send_transaction(signed_txn)
        print(f"Transaction submitted! TX ID: {txid}")

        # Wait for the transaction to be confirmed
        confirmed_txn = transaction.wait_for_confirmation(algod_client, txid, 4)
        print(f"Transaction confirmed in round: {confirmed_txn['confirmed-round']}")

    except Exception as e:
        print(f"An error occurred: {e}")

# --- Execute the transaction --- #
if __name__ == "__main__":
    send_algo_transaction()

To run this code:

  1. Replace YOUR_ALGOD_ADDRESS and YOUR_ALGOD_TOKEN with your node's details. If using Algorand Sandbox, the default address is http://localhost:4001 and the token is aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.
  2. Replace YOUR_25_WORD_MNEMONIC with the mnemonic phrase of your sender account.
  3. Replace RECIPIENT_ALGORAND_ADDRESS with the address that will receive the Algos.
  4. Save the code as a .py file (e.g., send_algo.py) and run it from your terminal: python send_algo.py.

If successful, you will see a transaction ID and a confirmation message indicating the round in which the transaction was included on the Algorand blockchain.

Common next steps

After successfully sending your first transaction, you can explore more advanced features offered by Algorand:

  • Algorand Standard Assets (ASAs): Learn how to create, manage, and transfer fungible and non-fungible tokens (NFTs) on the Algorand blockchain. ASAs are native to Layer 1, offering high performance and low costs Algorand Standard Assets documentation.
  • Smart Contracts (TEAL): Dive into Transaction Execution Approval Language (TEAL) to write secure and efficient smart contracts. These contracts can automate complex logic and enable decentralized applications (dApps) Algorand PyTeal smart contract guide.
  • Indexer: Utilize the Algorand Indexer to query historical data on the blockchain, such as transaction history for specific accounts, asset details, and smart contract states. This is crucial for building user-facing applications that require historical insights Algorand Indexer REST API reference.
  • Decentralized Applications (dApps): Explore frameworks and tools for building full-fledged dApps on Algorand, integrating front-end interfaces with your blockchain logic.
  • Ecosystem Tools: Investigate third-party tools, wallets, and services that integrate with Algorand, enhancing your development and deployment workflows.

Troubleshooting the first call

Encountering issues during your first Algorand API call or transaction submission is common. Here are some frequent problems and their solutions:

  • algosdk.error.AlgodHTTPError: POST http://localhost:4001/v2/transactions: 403 Forbidden: This usually means your algod_token is incorrect or missing. Double-check the token configured for your Algorand node. For Algorand Sandbox, the default token is a string of 64 'a' characters. For public node providers, ensure you're using the correct API key.
  • algosdk.error.AlgodHTTPError: POST http://localhost:4001/v2/transactions: 400 Bad Request - transaction rejected by network: account X does not exist: This error indicates that the sender's account address (X) is not recognized by the network, possibly because it has not received any transactions yet. Fund the account using the Algorand TestNet Dispenser or send a small amount of Algos to it from another existing account.
  • algosdk.error.AlgodHTTPError: POST http://localhost:4001/v2/transactions: 400 Bad Request - transaction rejected by network: account X balance Y too small to cover transaction: The sender account has insufficient Algos to cover the transaction fee (typically 0.001 Algo) and the minimum balance requirement. Ensure your account is funded with enough Algos. Remember that Algorand accounts have a minimum balance requirement (currently 0.1 Algo) to exist Algorand minimum balance requirements.
  • algosdk.error.AlgodHTTPError: HTTPConnectionPool(host='localhost', port=4001): Max retries exceeded with url: /v2/transactions (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')): Your application cannot connect to the Algorand node. Verify that your algod_address is correct and that the Algorand node (e.g., Algorand Sandbox or a remote AlgoNode) is running and accessible from your development environment. Check firewall settings or Docker container status if using Sandbox.
  • Incorrect Mnemonic/Private Key: If transactions are consistently failing with signature errors or invalid account errors, double-check that the mnemonic phrase or private key you are using correctly corresponds to the sender address and is properly converted. Tools like String.prototype.trim() can help remove accidental whitespace if copying and pasting.

For further assistance, the Algorand developer community forums and official documentation are valuable resources.