Skip to main content

GTX

Generic Transaction Protocol (GTX) is a protocol that's built on top of Generic Transfer Value (GTV), specifically focusing on how to encode transactions in a way that Postchain can comprehend.

Postchain uses GTX for sending and receiving transactions. It's not recommended to use GTV directly, even though it's possible to construct various Rell types directly into GTV.

GTX transaction format has the following features:

  • The format is based on ASN.1 DER serialization (standardized by ITU-T, ISO, IEC)
  • Has native support for multi-signature
  • Has native support for atomic transactions

GTX transaction consists of one or more operations; its name and list of arguments define each operation. For example, one transaction might encode two operations:

 issue(<Alice account ID>, 1000, USD)
transfer(<Alice account ID>, <Bob account ID>, 100, USD)

This looks similar to making function calls, so GTX operations can be understood as a kind of RPC, where the client submits calls (operations) to be performed on the server (network of Postchain nodes). GTX transaction is a batch of such operations signed by clients who wish to perform them. Usually, operations update the database, but they might only perform checks. GTX transaction is atomic; all operations succeed or fail as a whole.

GtxMessages DEFINITIONS ::= BEGIN

IMPORTS RawGtv FROM GtvMessages;

-- All types are using the same tags as RawGtv to make gtv<->gtx encoding equivalent

-- Gtx operation
-- [ string, [ gtv ] ]
RawGtxOp ::= [5] EXPLICIT SEQUENCE {
name [2] EXPLICIT UTF8String, -- RawGtv { string } --
args [5] EXPLICIT SEQUENCE OF RawGtv -- RawGtv { array } --
}

-- Gtx Body
-- [ bytearray, [ gtxOp ], [ bytearray ] ]
RawGtxBody ::= [5] EXPLICIT SEQUENCE {
blockchainRid [1] EXPLICIT OCTET STRING, -- RawGtv { bytearray } --
operations [5] EXPLICIT SEQUENCE OF RawGtxOp,
signers [5] EXPLICIT SEQUENCE OF [1] EXPLICIT OCTET STRING -- RawGtv { bytearray} --
}

-- Gtx
-- [ gtxBody, [ bytearray] ]
RawGtx ::= [5] EXPLICIT SEQUENCE {
body RawGtxBody,
signatures [5] EXPLICIT SEQUENCE OF [1] EXPLICIT OCTET STRING -- RawGtv { bytearray } --
}
END