Anoma Developer Documentation
  • Overview
  • Build
    • Getting Started
    • Your First Anoma App
      • Define a Resource
      • Write a Transaction Function
      • Write a Projection Function
      • Run your App
    • Anoma App Examples
  • LEARN
    • Overview
    • State Model
      • Model Comparison
    • Resource Machine
      • Information Flow Control
    • Resources
      • State
      • Logic
      • Kind
      • Lifecycle
    • Transactions
      • Delta
      • Actions
      • Balanced Transactions
      • Intents
    • Applications
      • Backend
      • Interface
    • Services
      • Indexing
      • Solving
Powered by GitBook
On this page
  • Transaction Functions
  • Projection Functions
  1. LEARN
  2. Applications

Interface

This page explains the application interface which is constituted by projection and transaction functions.

PreviousBackendNextServices

Last updated 1 month ago

The application interface consists of two components:

  1. Transaction functions representing the application write interface.

  2. Projection functions representing the application read interface.

Transaction Functions

Transaction functions take arbitrary input data and output a transaction object containing all required data (see the ). Besides populating the transaction object with the required , they also take care of checking the input arguments for correctness and can return error messages.

Transaction function examples are:

transfer (caller receiver : Identity) (toTransfer : Resource) : Transaction
  • A transfer function consuming an owned resource and creating one owned by a receiver.

merge (caller : Identity) : (toMerge : List Resource) : Transaction
  • A merge function merging a list of resources into one.

swap (caller : Identity) (give want : List Resources) : Transaction
  • A swap function consuming a list of resources and specifying a list of resource kinds and quantities that the caller wants to receive in return.

Projection Functions

Projection functions project data from the state (usually being fragmented into many different resources) into a format being useful to application users. As such, they take a list of resources as input and output arbitrary data.

Projection function examples are:

totalBalance (ownedTokens : List Resources) : Quantity
  • A totalBalance function returning the total quantity of resources of a specific kind being owned by an owner identity.

chatHistory (messages : List Resource) : List String
  • A chatHistory function returning the message texts of a message channel.

Commonly, the input resources passed to projection functions are obtained after indexing and custom-filtering, e.g., from an .

Anoma specs
indexing service provider