Transactions in Cellframe networks consist of a header and attached items.

The header contains information about the transaction hash and creation timestamp.

The properties of the transaction itself are determined by the set of attached items, the example below will list all types of available items for adding to the transaction.

There is placed a JSON Transaction Example in the end of the article.

JSON Format Transaction

{"method": "tx_create_json",
 
    "arguments": 
    {
       "net": "network name",
       "chain": "chain name",
    
       "tx_obj": 
       {
       
#transaction header
       "datum_hash": "",
       "ts_created": ,
       "datum_type": "tx",
       
#transaction items
       "items": 
       
        [   ITEMS ARE DESCRIBED BELOW    ]
        
        }
    },
    "id": "1"
}

TX ITEMS

Input

This item serves as a funds entering point into the transaction. The regular input can receive funds from the output of another previous transaction. For this out_prev_idx and prev_hash of the target transaction must be specified.

 {
    "type": "in",
    "prev_hash": "",
    "token": "",
    "out_prev_idx": ""
 }

Fields:

type - type of the item: "in" (string)
prev_hash - hash of previous transaction (string)
token - name of the token (string)
out_prev_idx - ID of the target output; ID is the serial number of OUT in the transaction starting with "0"  (uint64)

Conditional Input

This item is like regular input prescribed to receive incoming funds from the previous transaction, but conditional input can receive funds only from the conditional outputs. The fields are quite the same, but in case of service payment, there also must be specified receipt_idx of the receipt from the target transaction.

{
    "type": "in_cond", 
    "out_prev_idx": "",
    "prev_hash": "",
    "receipt_idx": "" 
}

Fields:

type - type of the item: "in_cond" (string)
prev_hash - hash of the target previous transaction (string)
token - name of the token (string)
out_prev_idx - ID of the target output; ID is the serial number of OUT in the transaction starting with "0"  (uint64)
receipt_idx - ID of the receipt (int) [optional field]

Output

The output item serves as an exit for funds from the transaction. Usually, funds are taken to Output from the Input or Conditional Input of the same transaction. But funds can be taken also from the INPUT EMISSION item.

To transfer funds from the output, it is mandatory to specify addr of the receiving wallet, token ticker and value of funds being transferred.

{
    "type": "out",
    "addr": "",
    "token": "",
    "value": ""
}

Fields:

type - type of the item: "out" (string)
addr - wallet address of the receiver (string)
token - name of the token (string)
value - amount of funds being transferred (string)

Conditional Outputs

These items are created to provide payments, exchanges, stakes and many more. These outputs differ from regular output with a special condition, which is being fulfilled to acquire funds.

1. Fee

This item is used to pay for validator services. Once the validator approves the transaction, funds from the conditional fee  output of this transaction can be transferred to his wallet. Almost every transaction includes this item, with very rare exceptions.

The recommended validator fee amount can be found here - fee.

{
    "type": "out_cond",
    "subtype": "fee",
    "service_id": "0x0000000000000000",
    "ts_expires": "never",
    "value": ""
}

Fields:

type - type of the item: "out_cond" (string)
subtype - subtype of the "cond_out" item : "fee" (string)
service_id - id of the service, "0x0000000000000000" by default (string)
ts_expires - timestamp of expiration specified in RFC822 format, if not specified,  "never" is used by default (string)
value - fee size (string)

2. Service Payment

An item designed for services payment in Cellframe networks.

To pay for the use of a service, you need to specify the fee value, the kind of a unit unit (megabytes or seconds), the maximal cost per one unit value_max_per_unit, as well as the provider’s public key pkey indicated in the receipt. If the provider’s public key matches the public key specified in the receipt, the provider will be able to withdraw funds from this conditional srv_pay output.

{
    "type": "out_cond",
    "subtype": "srv_pay",
    "service_id": "0x0000000000000001",
    "ts_expires": "",
    "value": "",
    "price_unit": "",
    "pkey": "",
    "value_max_per_unit": ""
}

Fields:

type - type of the item: "out_cond" (string)
subtype - subtype of the "cond_out" item : "srv_pay" (string)
service_id - id of the service, "0x0000000000000001" by default (string)
ts_expires - timestamp of expiration specified in RFC822 format, if not specified,  "never" is used by default (string)
value - payment sum (string)
price_unit - kind of service unit, "seconds" or "megabytes" (string)
pkey - public key of service-provider (string)
value_max_per_unit - maximal price for one unit (string)

3. Exchange Service

This item is designed for operations on the Cellframe Decentralized Exchange Service (DEX). It allows users to exchange tokens token at specified rate between users within a specific network net_id.

{
    "type": "out_cond",
    "subtype": "srv_xchange",
    "service_id": "0x2",
    "ts_expires": "",
    "value": "",
    "net_id": "",
    "token": "",
    "rate": ""
}

Fields:

type - type of the item: "out_cond" (string)
subtype - subtype of the "cond_out" item : "srv_xchange" (string)
service_id - id of the service, "0x2" by default (string)
ts_expires - timestamp of expiration specified in RFC822 format, if not specified,  "never" is used by default (string)
value - sum of tokens being exchanged (string)
net_id - ID of the network where order is placed (string)
token - ticker of token being bought (string)
rate - exchange rate calculated this way "token_buy/token_sell" (string)

Network ID's in the Cellframe:

Backbone - id=0x0404202200000000
KelVPN - id=0x1807202300000000
mileena - id=0x000000000000cccc
raiden - id=0x000000000000bbbb
riemann - id=0x000000000000dddd
subzero - id=0x000000000000acca

4. Staking Service

An item created for the staking service, specifically designed to lock a certain amount of funds value in a specified conditional output for a defined period of time time_unlock.

{
    "type": "out_cond",
    "subtype": "srv_stake_lock",
    "service_id": "0x12",
    "value": "",
    "time_unlock": ""
}

Fields:

type - type of the item: "out_cond" (string)
subtype - subtype of the "cond_out" item : "srv_stake_lock" (string)
service_id - id of the service, "0x12" by default (string)
value - amount of funds to lock (string)
time_unlock - timestamp in RFC822 format that specifies when the funds will be unlocked  (string)

5. Delegated Staking Service

This item is involved in the operation of the delegated staking service. With its help, you can delegate your “consensus weight” to another node signer_node_addr, meaning that your m-tokens from the address signing_addr in the amount of value will contribute to the total weight of the specified node.

{
    "type": "out_cond",
    "subtype": "srv_stake_pos_delegate",
    "service_id": "0x13",
    "ts_expires": "",
    "value": "",
    "signing_addr": "",
    "signer_node_addr": ""
}

Fields:

type - type of the item: "out_cond" (string)
subtype - subtype of the "cond_out" item:"srv_stake_pos_delegate" (string)
service_id - id of the service, "0x13" by default (string)
ts_expires - timestamp of expiration specified in RFC822 format, if not specified,  "never" is used by default (string)
value - amount of funds being delegated (string)
signing_addr - wallet address of the staker (string)
signer_node_address - node address of the target validator (string)

Voting

To create a poll transaction, this item is required.

The user who wants to initiate a poll must specify the question voting_question, the answer options answer_options, the maximum number of votes Votes max count, and the voting expiration time Voting expire. Additionally, options such as allowing participants to change their answer Changing vote is and the presence of a delegated key for participating in the vote Delegated key for participating in voting can be added.

{
    "type": "voting",
    "voting_question": "",
    "answer_options": "",
    "Voting expire" : "",
    "Votes max count" : "",
    "Changing vote is" : "available/not available",
    "Delegated key for participating in voting" : "required/not required"
}

Fields:

type - type of the item: "voting" (string)
voting_question - question which was put to a vote (string)
answer_options - available answers (string)
Voting expire - timestamp of poll expiration in RFC822 format (string)
Votes max count - manimal votes quantity (uint64)
Changing vote is - ability to change answer after voting: "available"/ "not available"(string)  [optional field]
Delegated key for participating in voting - necessity of delegated key for voting: "required"/ "not required" (string)  [optional field]

Vote

This item is used to participate in an already created poll. To vote, the user must specify in which voting voting_hash he wants to participate and select an answer option vote_answer_idx.

{
    "type": "vote",
    "voting_hash": "",
    "vote_answer_idx": ""
}

Fields:

type - type of the item: "vote" (string)
voting_hash - hash of the poll (string)
vote_answer_idx - ID of the answer option (uint64)

Signature

The signature is stored in this item. It contains a full signature hash sig_b64 in BASE64 format and its size.

{
    "type": "sign",
    "sig_b64": "",
    "sig_size": ""
}

Fields:

type - type of the item: "sign" (string)
sig_b64 - hash of the signature in BASE64 format (string)
sig_size - size of the signature in bytes (uint64)

Receipt

This item is used to issue a receipt for payment. The service provider specifies here the ID of the provided service service_id, the unit of service price_units (seconds or megabytes), the number of provided units and the total cost value.

{
    "type": "receipt",
    "service_id": "",
    "price_units": "",
    "units": "",
    "value": ""
}

Fields:

type - type of the item: "receipt" (string)
service_id - id of the provided service (string)
price_units - kind of service unit, "seconds" or "megabytes" (string)
units - quantity of provided service units (uint64)
value - total receipt sum (string)

TSD Section

This item stores the TSD section. Such a section is needed to add some data to a transaction.

{
    "type": "tsd",
    "type_tsd": "",
    "data": "",
    "size":
}

Fields:

type - type of the item: "data" (string)
type_tsd - type of TSD (uint64)
data - data which stores in the TSD section (string)
size - size of the item in bytes (uint64)

JSON Transaction

Example:

{
    "method": "tx_create_json",
    "arguments": {
        "net": "riemann",
        "chain": "main",
        "json_obj": {
            "datum_hash": "0xCA08FA00AC83C998D018882ED578413AC3BA97E90B53613ADE0BD28CAF9E2862",
            "ts_created": 1736949719,
            "datum_type": "tx",
            "items": [
                {
                    "type": "in",
                    "prev_hash": "0x61F07462EB6ACF53E826671E0D75D96EFD388FAAC2212727724F5EB2CFB7BCCC",
                    "out_prev_idx": 4
                },
                {
                    "type": "in",
                    "prev_hash": "0xF761A9A8C493CD42DE0BF04A607562B47EB762851D6870AD05F11DCBA3C5B547",
                    "out_prev_idx": 4
                },
                {
                    "type": "out_ext",
                    "addr": "o9z3wUTSTicckJuoxBh2u7xECZn1NT4kzbUd8YhNiPCmEH6tv9bRX5EoZTuhDA5fvttYgCFb73qGeH2FTicrVXrF1Z1YpECDkmmB7avQ",
                    "token": "mtKEL",
                    "value": "1000000000000000000"
                },
                {
                    "type": "out_ext",
                    "addr": "o9z3wUTSTicckJuoxkLc5q1CwaYs23474GbBm8ebgSZd1WmB7EhkPDpsoZPGX3hmhGa1wCqTDKgPjirbp3H45bg3tc6U5k8wCEJX575X",
                    "token": "tKEL",
                    "value": "2500000000000000"
                },
                {
                    "type": "out_cond",
                    "ts_expires": "never",
                    "value": "1990000000000000000",
                    "service_id": "0x0000000000000000",
                    "subtype": "fee"
                },
                {
                    "type": "out_ext",
                    "addr": "o9z3wUTSTicckJuovuVc2ZEPyP1so25LXUzfNHNwLZ3vVuJrjU6U3R2TjNeDYBvKFJF8UdJ2N18S4YBmKKAmSPPjC2XFwptedp6pW7fp",
                    "token": "tKEL",
                    "value": "999999999999898852810000000000000000"
                },
                {
                    "type": "out_ext",
                    "addr": "o9z3wUTSTicckJuovuVc2ZEPyP1so25LXUzfNHNwLZ3vVuJrjU6U3R2TjNeDYBvKFJF8UdJ2N18S4YBmKKAmSPPjC2XFwptedp6pW7fp",
                    "token": "mtKEL",
                    "value": "8700000000000000000"
                },
                {
                    "type": "sign",
                    "sig_type": "sig_dil",
                    "pub_key_size": 1196,
                    "sig_size": 2096,
                    "hash_type": 1,
                    "pub_key_b64": "rAQAAAAAAAABAAAAku... ...RRKJdBE=",
                    "sig_b64": "MAgAAAAAAAABAAAAHAgAAAAAAABi99QpI... ...B_sqPW_s="
                }
            ]
        }
    },
    "id": "1"
}