Skip to main content

What are Records?

Records are Leo’s primitive for representing owned, private data on the Aleo blockchain. They are similar to UTXOs (Unspent Transaction Outputs) in Bitcoin - each record has a unique owner and can only be consumed once.

Record Declaration

Records are declared using the record keyword:
Every record must include an owner field of type address. The owner is the only account that can spend or consume the record.

Record Fields

Records can contain multiple fields of different types:

Creating Records

In Functions

Create records by constructing them with all required fields:

With Self Reference

Use self.caller to create records for the transaction caller:

Consuming Records

Records are consumed when used as function inputs:
Once a record is consumed, it cannot be used again. The old record is destroyed and new records are created to represent the updated state.

Record Ownership

Owner Field

The owner field determines who can spend the record:

Transferring Ownership

Transfer records by creating new records with different owners:

Accessing Record Fields

Access record fields using dot notation:

Record Validation

Validate record data before processing:

Records vs Structs

Records

  • Must have an owner field
  • Represent owned, consumable assets
  • Are private by default
  • Can only be spent by the owner

Structs

  • No ownership requirement
  • Represent data structures
  • Can be used anywhere
  • Not consumable

Privacy Guarantees

Records provide strong privacy guarantees:
  1. Private Amounts: Record field values are not revealed on-chain
  2. Private Owners: Record owners are not publicly known
  3. Private Operations: Computations on records are private
  4. Zero-Knowledge Proofs: All record operations are proven without revealing data

Hybrid Public/Private Operations

Combine private records with public state:

Best Practices

1. Validate Before Consuming

2. Clear Ownership Transfer

3. Document Record Purpose

4. Handle Zero Amounts

Common Patterns

Splitting Records

Merging Records

Burning Records

Next Steps

Mappings

Store public state on-chain

Functions

Work with records in functions

Finalize

Combine records with public state

Data Types

Explore other types