description |
---|
This page explains the application interface which is constituted by projection and transaction functions. |
The application interface consists of two components:
- Transaction functions representing the application write interface.
- Projection functions representing the application read interface.
Transaction functions take arbitrary input data and output a transaction object containing all required data (see the Anoma specs). Besides populating the transaction object with the required data1, 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 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.
Footnotes
-
I.e., actions as well as commitments, nullifiers, and application data therein, proofs, the transaction delta value and state roots. ↩