---
# System prepended metadata

title: Compound Action

---

# Compound Action


Client-server architecture

client-string to the app-'server'-ring

what do we write in the log?

JSON-RPC 2.0
```json=
{
    "jsonrpc": "2.0",
    "method": "OUR_METHODS",
    "params": {
        "appId": "",
        "peerId": "",
        "metatx": "",
        "metatxSign": "",
        "record": "", // encoding of recordNode,EventNode,EncodedHeaderNode,EncodedBodyNode
        "body": "", // encoding of Message and (optionally) children
        "serviceKey": "", //PubKey
        "readkey": "",
    },
    "id": "<id>"
}
```

in a record_body we write (a) `message(s)`
a. as a node I only have a service key, no read key; so I cannot decrypt the body; no messages are passed to the application layer
b. as a node I have a service key and a read key, I can decode the body, and pass the cbor-encoded messages up to the application layer.

as a user:

    root-avatar
       |L_n
       |L_n-1
       |...
       |L_0
       
    in L_i
        |
        |
        |
        
    app-avatar (k devices, m logs)
        |L_(k_m)
        |
    this app-avatar can be read by the ring (public)

examples:
- client pushes obj to ring member
    - IPLD_Node of the object; CID_obj 
    - in metatx, `declareConstant` referencing CID_obj; tokenId and make ring spender
    - serialised_obj needs to be passed in (HTTP) request
    - write bodyNode with which references CID_obj

    ```json=
    {

    }
    ```
- text messaging
    - Alice messages Bob
    - Alice must open a cache in the ring caching for Bob (eg. 1KB for 24hrs)
        - Alice must pay for opening the cache upfront (mtx)
        - Alice must pay for each write to the cache (mtx)
        - Bob must pay to pull from the cache (payment channel)
        - ~~payments can be done over payment channel~~?
    - Alice puts a message to Bob in
    ```protobuf=
    message InterAvatarMessage {
        // A global address of a receiver's avatar.
        bytes globalAddressDestinationAvatar = 1;
        // Encrypted bytes of the string of the text message
        // with Bob's avatar public encryption key.
        bytes encryptedText = 2;
    }
    ```
    
    metatransaction
    
    ```golang=
    
    type Text struct {
        Txt string
    }
    ```

## stack rehash

     Application service
      ^
      | Messages
      v
     Mosaic Node, handling logs and clocks/contracts
         |- HTTP service
             |- accept requests


## Notes

NOTE: break ownership transfer of NDT into 2-step ownership transfer
    1. acknowledge ownership; accountability
    2. data transfer is not instantaneous;

GET: get doc
- GET requests can be grouped in a SWL record for the ring member

POST: post (new) doc
- idempotent
- new (append-only) doc to server
- each post creates a new SWL record for the ring member
- in mtx tokenId of Constant to share public information with the ring processing it: eg. my tracing marker
-> private: record only needs to be servicable/traversable (service key, not read key)
-> public: if logic is executed in mtx, at block-confirmation time;
HTTP response is:
1. check validity of compound action, signatures, (and simulated call); and respond good reception as a ring-member;
2. should 


## Random reference

## Scratchpad

