Docs
chromia.com

Generic Transaction Protocol (GTX)

The Generic Transaction Protocol (GTX) is a protocol built on top of the Generic Transfer Value (GTV). It focuses on how to encode transactions in a way that Postchain can process.

GTX provides three essential features that make it powerful and flexible:

  • Standard ASN.1 DER serialization, backed by ITU-T, ISO, and IEC
  • Built-in support for multi-signature transactions
  • Native atomic transaction handling

A GTX transaction operates through operations, where each operation has a name and a list of arguments. For example:

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

This structure functions like a Remote Procedure Call (RPC) system - the client submits operations to be executed by Postchain nodes. Each GTX transaction can contain multiple operations, and all operations within a transaction are atomic: they either all succeed or all fail together.

Text
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