# Generic Transfer Value (GTV) · Chromia Docs (concept)

> The Generic Transfer Value (GTV) protocol serves as the foundation for data serialization in Postchain.

Source: https://docs.chromia.com/get-started/about/protocols/gtv/

# Generic Transfer Value (GTV)

On this page

* [Type conversions](#type-conversions)
* [Strict type conversion](#strict-type-conversion)

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.

Rell

```
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 type** | **Operation input** | **Query input** | **Query Output** |
| --- | --- | --- | --- |
| rowid | GtvInteger | GtvInteger | GtvInteger |
| entity (becomes rowid) | GtvInteger | GtvInteger | GtvInteger |
| enum | GtvInteger | GtvInteger (can also be GtvString) | GtvString |
| struct | GtvArray | GtvArray (can also be GtvDict) | GtvDict |
| integer | GtvInteger | GtvInteger | GtvInteger |
| big\_integer | GtvBigInteger | GtvBigInteger | GtvBigInteger |
| decimal | GtvString | GtvString | GtvString |
| boolean | GtvInteger | GtvInteger | GtvInteger |
| json | GtvString | GtvString | GtvString |
| text | GtvString | GtvString | GtvString |
| byte\_array | GtvByteArray | GtvByteArray | GtvByteArray |
| nullable | GtvNull or Type | GtvNull or Type | GtvNull or Type |
| list | GtvArray | GtvArray | GtvArray |
| set | GtvArray | GtvArray | GtvArray |
| text map | GtvDict | GtvDict | GtvDict |
| non-text map (e.g., `[[k1, v1], [k2, v2], ...]`) | GtvArray | GtvArray | GtvArray |
| named tuple (e.g., `(x = 1, y = 2, z = 3)`) | GtvDict | GtvDict | GtvDict |
| unnamed tuple (e.g., `(1, 2, 3)`) | GtvArray | GtvArray | GtvArray |

## 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 type** | **Accepted types in strict** | **Accepted types in non-strict** |
| --- | --- | --- |
| byte\_array | GtvByteArray | GtvByteArray |
|  |  | GtvString |
|  |  |  |
| integer | GtvInteger | GtvInteger |
|  |  | GtvBigInteger |
|  |  |  |
| big\_integer | GtvBigInteger | GtvBigInteger |
|  |  | GtvInteger |
|  |  |  |
| decimal | GtvString | GtvString |
|  |  | GtvInteger |
|  |  | GtvBigInteger |
|  |  |  |

[View this page on docs.chromia.com](https://docs.chromia.com/get-started/about/protocols/gtv/)Content mirrored from the live docs
