Skip to content

Field Types

All supported field types, their byte sizes, TypeScript representations, and notes on how they're deserialized.

Numeric Types

TypeSizeTypeScriptEncoding
u81 bytenumberunsigned
u162 bytesnumberunsigned, little-endian
u324 bytesnumberunsigned, little-endian
u648 bytesbigintunsigned, little-endian
u12816 bytesbigintunsigned, little-endian
i81 bytenumbersigned two's complement
i162 bytesnumbersigned, little-endian
i324 bytesnumbersigned, little-endian
i648 bytesbigintsigned, little-endian
i12816 bytesbigintsigned, little-endian

bigint

u64, u128, i64, and i128 fields are typed as bigint in TypeScript. Use n suffix for literals: 1000n, { gt: 500n }.

Boolean

TypeSizeTypeScript
bool1 byteboolean

A bool field is true if the byte is 1, false if 0.

Public Key

TypeSizeTypeScript
publicKey32 bytesstring (base58)

Deserialized as a base58-encoded string. Use new PublicKey(field) from @solana/web3.js if you need a PublicKey object.

Variable-Length Types

TypeSizeTypeScriptEncoding
string4 + N bytesstringBorsh: u32 length prefix (LE) + UTF-8 bytes
bytes4 + N bytesstringBorsh: u32 length prefix (LE) + raw bytes → hex string

Variable-Length Fields and Offsets

Because string and bytes have dynamic sizes, the ORM cannot compute static byte offsets for any fields that come after them in the schema. Place variable-length fields last to preserve on-chain memcmp filtering for all preceding fixed-size fields.

Field Type Reference in Code

typescript
import type { FieldType } from '@curvhex/orm'

// All valid FieldType values:
type FieldType =
  | 'u8' | 'u16' | 'u32' | 'u64' | 'u128'
  | 'i8' | 'i16' | 'i32' | 'i64' | 'i128'
  | 'bool'
  | 'publicKey'
  | 'string'
  | 'bytes'

Planned Types

The following types are on the roadmap and not yet supported:

TypeNotes
enumMap u8 discriminant to string variants
option<T>Borsh option — 1-byte presence prefix
vec<T>Borsh vector — u32 length prefix + N elements

Released under the Apache 2.0 License.