ABI & ARC Standards
Understanding the Algorand Application Binary Interface and related standards.
What is the ABI?
The Algorand Application Binary Interface (ABI) defines how to interact with smart contracts in a standardized way. It specifies:
- How to encode/decode method arguments and return values
- Method signatures and selectors
- Type system for contract data
The ABI is defined in ARC-4 and extended by several other standards.
Key ARC Standards
The foundational standard defining how to call contract methods, encode parameters, and interpret return values. All ABI methods are identified by a 4-byte selector.
Standard for emitting events from contracts. Events are logged using a specific format that clients can parse and index.
The original specification format (.arc32.json) describing a contract's interface. Superseded by ARC-56.
The current standard (.arc56.json) with full state key definitions, box storage schemas, struct definitions, source maps, and detailed type information. This is what AVM Studio generates by default.
ARC-56 Application Specification
The ARC-56 spec ({Contract}.arc56.json) is a JSON document that fully describes a contract's interface. AVM Studio uses it for:
- Generating method call forms in the Explorer
- Decoding state values with proper types
- Validating method arguments
- Generating TypeScript client code
- Providing source maps for debugging
ARC-56 Structure
1{
2 "name": "Counter",
3 "desc": "A simple counter contract",
4 "methods": [
5 {
6 "name": "increment",
7 "args": [],
8 "returns": { "type": "uint64" },
9 "desc": "Increment the counter and return the new value"
10 },
11 {
12 "name": "getCount",
13 "args": [],
14 "returns": { "type": "uint64" },
15 "readonly": true,
16 "desc": "Get the current count without modifying state"
17 }
18 ],
19 "state": {
20 "schema": {
21 "global": { "ints": 1, "bytes": 0 },
22 "local": { "ints": 0, "bytes": 0 }
23 },
24 "keys": {
25 "global": {
26 "count": {
27 "key": "count",
28 "keyType": "bytes",
29 "valueType": "uint64",
30 "desc": "The current counter value"
31 }
32 }
33 }
34 }
35}
{ContractName}.arc56.json and included in the build artifacts.ABI Type System
The ABI defines a comprehensive type system for encoding data:
Basic Types
| Type | Description | Example |
|---|---|---|
uint64 | 64-bit unsigned integer | 1000000 |
uint8 - uint512 | Unsigned integers (8-512 bits) | 255 |
bool | Boolean value | true |
address | 32-byte Algorand address | ABC...XYZ |
byte | Single byte | 0xFF |
string | UTF-8 string (variable length) | "hello" |
Compound Types
| Type | Description | Example |
|---|---|---|
uint64[] | Dynamic array | [1, 2, 3] |
uint64[3] | Fixed-size array | [1, 2, 3] |
byte[32] | Fixed-size byte array | Hash/key bytes |
(uint64,address) | Tuple | [100, "ABC..."] |
Transaction Reference Types
| Type | Description |
|---|---|
txn | Any transaction in the group |
pay | Payment transaction |
axfer | Asset transfer transaction |
appl | Application call transaction |
acfg | Asset config transaction |
Method Selectors
ABI methods are identified by a 4-byte selector computed from the method signature:
1Method: increment()uint64
2Signature: "increment()uint64"
3Selector: SHA512/256("increment()uint64")[0:4] = 0x1a2b3c4d
When calling a contract, the first application argument contains the method selector.
State Schema
The AppSpec defines how much state the contract uses:
Global State
Shared storage accessible by all users. Limited to 64 key-value pairs.
- ints - Number of uint64 values
- bytes - Number of byte slice values
Local State
Per-account storage for users who opt in. Limited to 16 key-value pairs per account.
Box Storage
Flexible storage with named boxes up to 32KB each. ARC-56 adds schemas for box definitions.
1{
2 "state": {
3 "keys": {
4 "box": {
5 "users": {
6 "keyType": "address",
7 "valueType": "(uint64,string)",
8 "prefix": "u_",
9 "desc": "User profile data"
10 }
11 }
12 }
13 }
14}
Events (ARC-28)
Contracts can emit events that are logged on-chain and can be indexed by clients:
1{
2 "events": [
3 {
4 "name": "Transfer",
5 "args": [
6 { "name": "from", "type": "address" },
7 { "name": "to", "type": "address" },
8 { "name": "amount", "type": "uint64" }
9 ],
10 "desc": "Emitted when tokens are transferred"
11 }
12 ]
13}
Events are emitted via the log opcode with a specific encoding format.
Generated TypeScript Clients
AVM Studio generates TypeScript client code ({Contract}Client.ts) from the ARC-56 spec:
1// Auto-generated from Counter.arc56.json
2import { AlgorandClient } from '@algorandfoundation/algokit-utils';
3
4export class CounterClient {
5 async increment(): Promise<bigint> {
6 // Type-safe method call with automatic ABI encoding
7 }
8
9 async getCount(): Promise<bigint> {
10 // Read-only method (uses simulate, no transaction)
11 }
12}
The generated client provides type-safe methods matching the contract's ABI, with automatic encoding/decoding of arguments and return values.
Importing External Contracts
You can import deployed contracts by providing their ARC-56 or ARC-32 specification:
- Go to the Explorer
- Click Import Contract
- Enter the App ID and select the network
- Upload the
.arc56.jsonor.arc32.jsonfile - The contract is now available with full ABI support
.arc56.json file.