Skip to main content

Generic Transfer Value (GTV)

The Generic Transfer Value (GTV) protocol serves as the foundation for data serialization in Postchain. It supports a comprehensive range of data types:

  • Primitive types: integers, big integers, strings and byte arrays
  • Complex types: arrays and dictionaries

All GTV data is serialized using the ASN.1 DER format for transmission.

GtvMessages DEFINITIONS ::= BEGIN

DictPair ::= SEQUENCE {
name UTF8String,
value RawGtv
}

RawGtv ::= CHOICE {
null [0] NULL,
byteArray [1] OCTET STRING,
string [2] UTF8String,
integer [3] INTEGER,
dict [4] SEQUENCE OF DictPair,
array [5] SEQUENCE OF RawGtv,
bigInteger [6] INTEGER
}

END

Type conversions​

The following table shows how Rell types are converted to and from GTV types in different contexts:

Rell typeOperation inputQuery inputQuery Output
rowidGtvIntegerGtvIntegerGtvInteger
entity (becomes rowid)GtvIntegerGtvIntegerGtvInteger
enumGtvIntegerGtvInteger (can also be GtvString)GtvString
structGtvArrayGtvArray (can also be GtvDict)GtvDict
integerGtvIntegerGtvIntegerGtvInteger
big_integerGtvBigIntegerGtvBigIntegerGtvBigInteger
decimalGtvStringGtvStringGtvString
booleanGtvIntegerGtvIntegerGtvInteger
jsonGtvStringGtvStringGtvString
textGtvStringGtvStringGtvString
byte_arrayGtvByteArrayGtvByteArrayGtvByteArray
nullableGtvNull or TypeGtvNull or TypeGtvNull or Type
listGtvArrayGtvArrayGtvArray
setGtvArrayGtvArrayGtvArray
text mapGtvDictGtvDictGtvDict
non-text map (e.g., [[k1, v1], [k2, v2], ...])GtvArrayGtvArrayGtvArray
named tuple (e.g., (x = 1, y = 2, z = 3))GtvDictGtvDictGtvDict
unnamed tuple (e.g., (1, 2, 3))GtvArrayGtvArrayGtvArray

Strict type conversion​

With Rell Version 0.13.9, type conversion has become stricter by default. The following table shows the differences between strict and non-strict type handling:

Operation input Rell typeAccepted types in strictAccepted types in non-strict
byte_arrayGtvByteArrayGtvByteArray
GtvString
integerGtvIntegerGtvInteger
GtvBigInteger
big_integerGtvBigIntegerGtvBigInteger
GtvInteger
decimalGtvStringGtvString
GtvInteger
GtvBigInteger