# Exchange Transaction Binary Format
Learn more about Exchange transaction.
# Version 3
Binary format of version 3 is defined in transaction.proto protobuf scheme. The fields that are common to all types of transactions are described in the Transaction Binary Format article.
Exchange transaction of version 3 can accept orders of versions 1–4.
Version 3 is enabled by feature #15 “Ride V4, VRF, Protobuf, Failed transactions”.
message ExchangeTransactionData {
int64 amount = 1;
int64 price = 2;
int64 buy_matcher_fee = 3;
int64 sell_matcher_fee = 4;
repeated Order orders = 5;
};
Field | Size | Description |
---|---|---|
amount | 8 bytes | Amount of the amount asset (base currency) that the buyer received from the seller, specified in the minimum fraction (“cent”) of asset |
price | 8 bytes | Price for the amount asset (base currency) nominated in the price asset (quote currency), multiplied by 108. For more details see the Order article |
buy_matcher_fee | 8 bytes | Buy matcher fee. The fee token ID is indicated in buy order |
sell_matcher_fee | 8 bytes | Sell matcher fee The fee token ID is indicated in sell order |
orders | Buy order and sell order. See the Order binary format |
# Version 2
Transaction version 2 can accept orders of version 1, 2 and 3.
# | Field | JSON field name | Field type | Field size in bytes | Comment |
---|---|---|---|---|---|
1 | Version flag | Byte | 1 | Indicates the transaction version is 2 or higher. Value must be 0 | |
2 | Transaction type ID | type | Byte | 1 | Value must be 7 |
3 | Transaction version | version | Byte | 1 | Value must be 2 |
4.1 | Buy order size | Int | 4 | Size including flag 4.2 | |
4.2 | Buy order version flag | order1.version | Byte | S | S = 1 if the order version is 1.S = 0 if the order version is 2 or 3 |
4.3 | Buy order | order1 | Array[Byte] | See Order Binary Format | |
5.1 | Sell order size | Int | 4 | Size including flag 5.2 | |
5.2 | Sell order version flag | order2.version | Byte | S | S = 1 if the order version is 1.S = 0 if the order version is 2 or 3 |
5.3 | Sell order | order2 | Array[Byte] | See Order Binary Format | |
6 | Deal price | price | Long | 8 | Price for the amount asset (base currency) nominated in the price asset (quote currency) |
7 | Amount | amount | Long | 8 | Amount of the amount asset (base currency) that the buyer received from the seller |
8 | Buy matcher fee | buyMatcherFee | Long | 8 | |
9 | Sell matcher fee | sellMatcherFee | Long | 8 | |
10 | Transaction fee | fee | Long | 8 | |
11 | Transaction timestamp | timestamp | Long | 8 | |
12 | Transaction proofs | proofs | See Transaction Proofs Binary Format | S | If the array is empty, then S = 3. If the array is not empty, then S = 3 + 2 × N + 64 × N , where N is the number of proofs in the array.The maximum number of proofs in the array is 8. The size of each proof is 64 bytes |
The fields numbered in bold are the transaction body bytes.
# JSON Representation of Transaction
See the example in Node API.
# Version 1
Transaction version 1 can accept orders of version 1 only.
# | Field | Field type | Field size in bytes | Comment |
---|---|---|---|---|
1 | Transaction type ID | Byte | 1 | Value must be 6 |
2 | Buy order size | Int | 4 | |
3 | Sell order size | Int | 4 | |
4 | Buy order | Array[Byte] | See order binary format | |
5 | Sell order | Array[Byte] | See order binary format | |
6 | Deal price | Long | 8 | Price for the amount asset (base currency) nominated in the price asset (quote currency) |
7 | Amount | Long | 8 | Amount of the amount asset (base currency) that the buyer received from the seller |
8 | Buy matcher fee | Long | 8 | |
9 | Sell matcher fee | Long | 8 | |
10 | Transaction fee | Long | 8 | |
11 | Transaction timestamp | Long | 8 | |
12 | Transaction signature | Array[Byte] | 64 |
The fields numbered in bold are the transaction body bytes.