Skip to content

Smart Contract Costs & Constraints

This page covers the costs and constraints specific to smart contract development on Algorand. For a complete list of all protocol parameters including transaction fees, minimum balances, and other network-wide settings, see the main protocol parameters page.

Program Constraints

Program Size Limits

TypeConstraint
Logic SignaturesMax size: 1000 bytes for logic signatures (consensus parameter LogicSigMaxSize). Components: The bytecode plus the length of all arguments
Smart ContractsMax size: 2048*(1+ExtraProgramPages) bytes Components: ApprovalProgram + ClearStateProgram

Application Call Arguments

ParameterConstraint
Number of ArgumentsMaximum 16 arguments can be passed to an application call. This limit is defined by the consensus parameter MaxAppArgs
Combined Size of ArgumentsThe maximum combined size of arguments is 2048 bytes. This limit is defined by the consensus parameter MaxAppTotalArgLen
Max Size of Compiled TEAL CodeThe maximum size of compiled TEAL code combined with arguments is 1000 bytes. This limit is defined by the consensus parameter LogicSigMaxSize
Max Cost of TEAL CodeThe maximum cost of TEAL code is 20000 for logic signatures and 700 for smart contracts. These limits are defined by the consensus parameters LogicSigMaxCost and MaxAppProgramCost respectively
Argument TypesThe arguments to pass to the ABI call can be one of the following types: boolean, number, bigint, string, Uint8Array, an array of one of the above types, algosdk.TransactionWithSigner, TransactionToSign, algosdk.Transaction, Promise<SendTransactionResult>. These types are used when specifying the ABIAppCallArgs for an application call

Opcode Constraints

In Algorand, the opcode budget measures the computational cost of executing a smart contract or logic signature. Each opcode (operation code) in the Algorand Virtual Machine (AVM) has an associated cost deducted from the opcode budget during execution.

ParameterConstraint
Cost of OpcodesMost opcodes have a computational cost of 1. Some operations (e.g., SHA256, keccak256, sha512_256, ed25519verify) have larger costs.
Budget ConstraintsMax opcode budget: Smart signatures: 20,000 units Smart contracts invoked by a single application transaction: 700 units. If invoked via a group: 700 * number of application transactions.
Clear State ProgramsInitial pooled budget must be >= 700 units or higher. Execution limit: 700 units.

Note: Algorand Python provides a helper method for increasing the available opcode budget, see algopy.ensure_budget.

Stack

In Algorand’s Algorand Virtual Machine (AVM), the stack is a key component of the execution environment.

ParameterConstraint
Maximum Stack Depth1000. If the stack depth is exceeded, the program fails.
Item Size LimitsThe stack can contain values of either uint64 or byte-arrays. Byte-arrays may not exceed 4096 bytes in length.
Type LimitationEvery element of the stack is restricted to the types uint64 and bytes.
Item Size LimitMaximum size for byte arrays is 4096 bytes. Maximum value uint64 is 18446744073709551615.
Operation FailureFails if an opcode accesses a position in the stack that does not exist.

Resources

In Algorand, the access and usage of resources such as account balance/state, application state, etc., by applications are subject to certain constraints and costs:

Resource Access Limit

AspectConstraint
Access RestrictionsLimited access to resources like account balance and application state to ensure efficient block evaluation.
Specification RequirementResources must be specified within the transaction for nodes to pre-fetch data.

Access Constraints

Access TypeConstraint
Block InformationPrograms cannot access information from previous blocks.
Transaction InformationCannot access other transactions in the current block unless part of the same atomic transaction group.

Logic Signatures

ParameterConstraint
Transaction CommitmentCannot determine the exact round or time of transaction commitment.
Stateless ProgramsCannot query account balances or asset holdings. Transactions must comply with standard accounting rules and may fail if rules are violated.

AVM Environment

ParameterConstraint
Indirect JumpsNot supported; all jumps must reference specific addresses.

Storage Constraints

Storage StructureKey LengthValue LengthUnique Key RequirementAdditional DetailsSafety from Unexpected Deletion
Local State StorageUp to 64 bytesKey + value ≤ 128 bytesYesLarger datasets require partitioningNot Safe — Can be cleared by users at any time using ClearState transactions
Box Storage1 to 64 bytesUp to 32KB (32,768 bytes)YesKey does not contribute to box size and values > 1,024 bytes need additional referencesBoxes persist after app deletion but lock the minimum balance if not deleted beforehand
Global State StorageUp to 64 bytesKey + value ≤ 128 bytesYesLarger datasets require partitioningSafe — Deleted only with the application; otherwise, data is safe from unexpected deletion