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 **[[3. JSON Format of Transactions#JSON Transaction|JSON Transaction Example]]** in the end of the article. ## JSON Format Transaction ```json {"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 - **[[3. JSON Format of Transactions#Input|Input]]** - **[[3. JSON Format of Transactions#Conditional Input|Conditional Input]]** - **[[3. JSON Format of Transactions#Output|Output]]** - **[[3. JSON Format of Transactions#1. Fee|Conditional Out - Fee]]** - **[[3. JSON Format of Transactions#2. Service Payment|Conditional Out - Service Payment]]** - **[[3. JSON Format of Transactions#3. Exchange Service|Conditional Out - Exchange Service]]** - **[[3. JSON Format of Transactions#4. Staking Service|Conditional Out - Staking Service]]** - **[[3. JSON Format of Transactions#5. Delegated Staking Service|Conditional Out - Delegated Staking Service]]** - **[[3. JSON Format of Transactions#Voting|Voting]]** - **[[3. JSON Format of Transactions#Vote|Vote]]** - **[[3. JSON Format of Transactions#Signature|Signature]]** - **[[3. JSON Format of Transactions#Receipt|Receipt]]** - **[[3. JSON Format of Transactions#TSD Section|TSD Section]]** ### Input This item serves as a funds entering point into the transaction. The regular **input** can receive funds from the [[3. JSON Format of Transactions#Output|output]] of another previous transaction. For this **`out_prev_idx`** and **`prev_hash`** of the target transaction must be specified. ```json { "type": "in", "prev_hash": "", "token": "", "out_prev_idx": "" } ``` `Fields:` ```actionscript 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 **[[3. JSON Format of Transactions#Input|input]]** prescribed to receive incoming funds from the previous transaction, but **[[3. JSON Format of Transactions#Conditional Input|conditional input]]** can receive funds only from the **[[3. JSON Format of Transactions#Conditional Outputs|conditional outputs]]**. The fields are quite the same, but in case of service payment, there also must be specified **`receipt_idx`** of the **[[Receipt|receipt]]** from the target transaction. ```json { "type": "in_cond", "out_prev_idx": "", "prev_hash": "", "receipt_idx": "" } ``` `Fields:` ```actionscript 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. ```json { "type": "out", "addr": "", "token": "", "value": "" } ``` `Fields:` ```actionscript 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]]**. ```json { "type": "out_cond", "subtype": "fee", "service_id": "0x0000000000000000", "ts_expires": "never", "value": "" } ``` `Fields:` ```actionscript 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 [[3. JSON Format of Transactions#Receipt|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. ```json { "type": "out_cond", "subtype": "srv_pay", "service_id": "0x0000000000000001", "ts_expires": "", "value": "", "price_unit": "", "pkey": "", "value_max_per_unit": "" } ``` `Fields:` ```actionscript 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`**. ```json { "type": "out_cond", "subtype": "srv_xchange", "service_id": "0x2", "ts_expires": "", "value": "", "net_id": "", "token": "", "rate": "" } ``` `Fields:` ```actionscript 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:` ```actionscript 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 **[[Stake|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`**. ```json { "type": "out_cond", "subtype": "srv_stake_lock", "service_id": "0x12", "value": "", "time_unlock": "" } ``` `Fields:` ```actionscript 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 Stakes|delegated staking]]** service. With its help, you can delegate your "consensus weight" to another node **`signer_node_addr`**, meaning that your **[[Token Delegated (m-token)|m-tokens]]** from the address **`signing_addr`** in the amount of **`value`** will contribute to the total weight of the specified node. ```json { "type": "out_cond", "subtype": "srv_stake_pos_delegate", "service_id": "0x13", "ts_expires": "", "value": "", "signing_addr": "", "signer_node_addr": "" } ``` `Fields:` ```actionscript 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 **[[2. Transactions Functions#Voting service|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. ```json { "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:` ```actionscript 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`**. ```json { "type": "vote", "voting_hash": "", "vote_answer_idx": "" } ``` `Fields:` ```actionscript 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. ```json { "type": "sign", "sig_b64": "", "sig_size": "" } ``` `Fields:` ```actionscript 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 **[[3. JSON Format of Transactions#Receipt|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`**. ```json { "type": "receipt", "service_id": "", "price_units": "", "units": "", "value": "" } ``` `Fields:` ```actionscript 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. ```json { "type": "tsd", "type_tsd": "", "data": "", "size": } ``` `Fields:` ```actionscript 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: ```json { "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" } ```