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
  1. LEARN
  2. Transactions

Intents

This page explains how intents and solving works within the Anoma protocol.

PreviousBalanced TransactionsNextApplications

Last updated 20 days ago

Intents, which are unbalanced transactions, can be become balanced transactions through composition with matching intents by other counterparties.

Anoma users submit their intents to an intent pool in the form of unbalanced transactions, which are received and processed by that output . These transactions are then ordered and finally sent to the executor node, which verifies and executes the transactions in the determined order, updating the state.

Below, we show examples of a balanced transaction that can directly be executed and two flavors of intents (unbalanced transactions) requiring counterparty discovery.

Legend

  • Symbols, e.g., ๐Ÿ , indicate resource objects of specific kind that can contain arbitrary data and logic.

  • Numbers Preceeding numbers, e.g., 4๐Ÿโ€‰ indicate the quantity of resources.

  • Names following a resource, e.g., 4๐Ÿโ€‰Alice , indicate who is authorized to consume it.

  • Blue coloring indicates ephemeral resources.

  • Speech bubbles ๐Ÿ’ฌ indicate ephemeral, constraint-carrying resources.

Alice and Bob own apple ๐Ÿ and banana ๐ŸŒ resources. Both want to swap their fruits and know exactly what they want. Both don't need to know each other.

Alice's intent

"I want to give 3๐Ÿ for 2๐ŸŒ."

Consume
Create

3๐Ÿโ€‰Alice

2๐ŸŒโ€‰Alice

Bob's intent

"I want to give 2๐ŸŒ for 3๐Ÿ."

Consume
Create

2๐ŸŒโ€‰Bob

3๐Ÿโ€‰Bob

Balanced txn (composition of Alice's and Bob's unbalanced txns)

Anyone seeing the two transactions (including Alice and Bob themselves) can compose the unbalanced transactions to obtain a balanced transaction containing two actions.

Consume
Create

3๐Ÿโ€‰Alice

2๐ŸŒโ€‰Alice

// Action Separator

2๐ŸŒโ€‰Bob

3๐Ÿโ€‰Bob

After execution,

  • Alice has swapped her 3๐Ÿโ€‰Alice resource for a 2๐ŸŒโ€‰Alice resource,

  • Bob has swapped his 2๐ŸŒโ€‰Bob for a 3๐Ÿโ€‰Bob resource.

This outcome is equivalent to two balanced transactions (see the previous tab) where both, Alice and Bob, transfer resources to one another.

Alice and Bob own apple ๐Ÿ and banana ๐ŸŒ resources. Both want to swap some of their fruits within specific constraints. Both don't know each other.

Both, Alice and Bob express their desired outcomes in ephemeral, constraint-carrying resource ๐Ÿ’ฌ to solver Sally.

Alice's Intent

"Sally, I want to give exactly 4๐Ÿ for at least 4๐ŸŒ."

Consume
Create

4๐Ÿโ€‰Alice

1๐Ÿ’ฌโ€‰Sally,โ€‰giveโ€‰=โ€‰4๐Ÿโ€‰Alice,โ€‰wantโ€‰โ‰ฅโ€‰4๐ŸŒโ€‰Alice

Bob's Intent

"Sally, I want to give at most 7๐ŸŒ for exactly 3๐Ÿ."

Consume
Create

7๐ŸŒโ€‰Bob

1๐Ÿ’ฌโ€‰Sally,โ€‰giveโ€‰โ‰คโ€‰7๐ŸŒโ€‰Bob,โ€‰wantโ€‰=โ€‰3๐Ÿโ€‰Bob

Sally's Solving Intent

Seeing both intents in the intent pool, Sally comes up with a solution.

"I'll give 3๐Ÿ to Bob and take 1๐Ÿ for myself as a fee. Furthermore, I'll give 5๐ŸŒ to Alice, return 1๐ŸŒ to Bob, and take 1๐ŸŒ for myself as a fee."

Consume
Create

1๐Ÿ’ฌโ€‰Sally,โ€‰giveโ€‰=โ€‰4๐Ÿโ€‰Alice,โ€‰wantโ€‰โ‰ฅโ€‰4๐ŸŒโ€‰Alice

3๐Ÿโ€‰Bob

1๐Ÿ’ฌโ€‰Sally,โ€‰giveโ€‰โ‰คโ€‰7๐ŸŒโ€‰Bob,โ€‰wantโ€‰=โ€‰3๐Ÿโ€‰Bob

1๐Ÿโ€‰Sally

5๐ŸŒโ€‰Alice

1๐ŸŒโ€‰Bob

1๐ŸŒโ€‰Sally

Balanced Transaction (composition of Alice's, Bob's, and Sally's intents)

Sally composes her solution intent with Alice's and Bob's intents and obtains a balanced transaction containing three actions.

Consume
Create

4๐Ÿโ€‰Alice

1๐Ÿ’ฌโ€‰Sally,โ€‰giveโ€‰=โ€‰4๐Ÿโ€‰Alice,โ€‰wantโ€‰โ‰ฅโ€‰4๐ŸŒโ€‰Alice

// Action Separator

7๐ŸŒโ€‰Bob

1๐Ÿ’ฌโ€‰Sally,โ€‰giveโ€‰โ‰คโ€‰7๐ŸŒโ€‰Bob,โ€‰wantโ€‰=โ€‰3๐Ÿโ€‰Bob

// Action Separator

1๐Ÿ’ฌโ€‰Sally,โ€‰giveโ€‰=โ€‰4๐Ÿโ€‰Alice,โ€‰wantโ€‰โ‰ฅโ€‰4๐ŸŒโ€‰Alice

3๐Ÿโ€‰Bob

1๐Ÿ’ฌโ€‰Sally,โ€‰giveโ€‰โ‰คโ€‰7๐ŸŒโ€‰Bob,โ€‰wantโ€‰=โ€‰3๐Ÿโ€‰Bob

1๐Ÿโ€‰Sally

5๐ŸŒโ€‰Alice

1๐ŸŒโ€‰Bob

1๐ŸŒโ€‰Sally

After execution,

  • Alice gave her 4๐Ÿ and got 5๐ŸŒ , more than the least amount she specified,

  • Bob gave 6๐ŸŒ and has 1๐ŸŒ left, less than the maximal amount he specified, and got the 3๐Ÿ apples he wanted,

Sally took 1๐Ÿ and 1๐ŸŒ for her services. If she is taking too much for herself, users might decide to not let her settle their intents anymore (see the ).

solvers
balanced transactions
Slow Games ART