Funding an Account | Algorand Developer Portal

Funding an Account

To use the Algorand blockchain, accounts need to be funded with ALGO tokens. This guide explains different methods of funding accounts across Algorand’s various networks. You can also transfer ALGO tokens from an existing funded account to a new account using the Algorand SDK or through wallet applications. All Algorand accounts require a minimum balance to be registered in the ledger. The specific method you choose will depend on whether you’re working with MainNet, TestNet, or LocalNet.

Choosing the Right Funding Method

The appropriate funding method depends on your specific needs:

By selecting the right funding mechanism for your use case, you can streamline development and ensure your Algorand applications have the resources they need to operate effectively.

LocalNet Funding Options

LocalNet provides pre-funded accounts for development and testing. You can use these existing accounts or create and fund new ones using various mechanisms.

Retrieving the Default LocalNet Dispenser

This utils function retrieves the default LocalNet dispenser account, which is pre-funded and can be used to provide ALGOs to other accounts in a local development environment. The LocalNet dispenser is automatically available and is designed for testing purposes, making it easy to create and fund new accounts without external dependencies.

/**
 * Get the default LocalNet dispenser account that can be used to fund other accounts
 */
const localNetDispenser = await algorand.account.localNetDispenser()
"""
Returns the default LocalNet dispenser account.
This account can be used to fund test accounts on LocalNet.
"""
localnet_dispenser = algorand_client.account.localnet_dispenser()

Environment-Based Dispenser

The below function retrieves a dispenser account configured through environment variables. It allows developers to specify a custom funding account for different environments (e.g., development, testing, staging). The function looks for environment variables containing the dispenser’s private key or mnemonic, making it flexible for dynamic funding configurations across various deployments.

/**
 * Get a dispenser account from environment variables.
 */
const environmentDispenser = await algorand.account.dispenserFromEnvironment()
"""
Returns an account (with private key loaded) that can act as a dispenser from environment variables.
If environment variables are not present, returns the default LocalNet dispenser account.
"""
dispenser = algorand_client.account.dispenser_from_environment()

TestNet Funding Options

TestNet Faucet

Algorand provides a faucet for funding TestNet accounts with test ALGO tokens for development purposes.

  1. Visit Lora Explorer and choose the network(localnet or testnet) or visit the Algorand TestNet Dispenser
  2. Sign in with your Google account and complete the reCAPTCHA
  3. Enter your Algorand TestNet address
  4. Click “Dispense” to receive test ALGOs

TestNet Dispenser API

For developers needing programmatic access to TestNet funds, AlgoKit provides utils to interact with the TestNet Dispenser API.

Ensuring Funds from TestNet Dispenser

The ensureFundedFromTestNetDispenserApi function checks if a specified Algorand account has enough funds on TestNet. If the balance is below the required threshold, it automatically requests additional ALGOs from the TestNet Dispenser API.

/**
 * Ensure an account has sufficient funds using the TestNet Dispenser API
 * The dispenser client uses the `ALGOKIT_DISPENSER_ACCESS_TOKEN` environment variable
 * to authenticate with the dispenser API.
 */
const dispenserClient = algorand.client.getTestNetDispenserFromEnvironment()
await algorand.account.ensureFundedFromTestNetDispenserApi('ACCOUNTADDRESS', dispenserClient, algo(1))

Directly Funding an Account

The below utils function sends a fixed amount of ALGOs (1,000,000 microALGOs = 1 ALGO) to a specified account using the TestNet Dispenser API.

/**
 * Directly fund an account using the TestNet Dispenser API
 */
const testnetDispenser = algorand.client.getTestNetDispenserFromEnvironment()
await testnetDispenser.fund('ACCOUNTADDRESS', 1_000_000)

Using AlgoKit CLI

The AlgoKit CLI provides a simple command-line interface for funding accounts. This command directly funds the specified receiver address with the requested amount of ALGOs using the TestNet Dispenser.

algokit dispenser fund --receiver <address> --amount <amount>

MainNet On-Ramps

For MainNet transactions, users must acquire real ALGO tokens through cryptocurrency exchanges or other on-ramp services. Required for real-world transactions and decentralized applications. Some of the common On-Ramps are centralized exchanges like Coinbase, Decentralized Exchanges like Tinyman, other DeFi protocols like Folks Finance.

AlgoKit Utils Funding Helpers

AlgoKit provides utility functions to help ensure accounts have sufficient funds, which is particularly useful for automation and deployment scripts.

Ensure Funded

The below code checks the balance of a specified account and transfers ALGOs from a dispenser if the balance falls below the required threshold (1 ALGO in this example).

/**
 * Ensure an account has sufficient funds by transferring
 * Algos from a dispenser account if needed
 */
await algorand.account.ensureFunded('ACCOUNTADDRESS', localNetDispenser, algo(1))

Funding from Environment Variables

This code combines the ensure-funded mechanism with an environment-configured dispenser. It retrieves a dispenser account from environment variables and uses it to top up the target account if its balance is below 1 ALGO.

/**
 * Ensure an account has sufficient funds using a dispenser account
 * loaded from environment variables
 */
await algorand.account.ensureFundedFromEnvironment('ACCOUNTADDRESS', algo(1))