Interface

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

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. 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 indexing service provider.

Last updated