Skip to content

Storage Overview

Xian contract state is exposed through four ORM-style primitives:

  • Variable
  • Hash
  • ForeignVariable
  • ForeignHash

All of them ultimately map to deterministic key-value storage in LMDB.

What to Use

PrimitiveUse
Variableone stored value
Hashkeyed or multi-dimensional data
ForeignVariableread another contract's variable
ForeignHashread another contract's hash

Key Facts

  • Variable uses .set() and .get()
  • Hash uses index syntax like balances["alice"]
  • hash keys can be multi-dimensional
  • foreign storage is read-only by design
  • values are encoded deterministically for consensus safety

Use the pages in this section for the exact behavior of each primitive.