Docs Técnicas
Types
TREA is statically typed.
TREA is statically typed.
Primitive Types
bool
u8
u16
u32
u64
u128
u256
i64
i128
Address
String
AssetId
Hash256
PercentAddress is a real account or contract address. It is non-zero by default: runtime effects and storage writes reject the empty/zero address. Do not use a zero address as an absence marker or burn sink; model absence with explicit state, and use ledger burn/retirement mechanisms for destruction.
Financial Types
Money[ASSET]
Account[ASSET]Money[...] exists in the type system, but the executable safety envelope rejects it in:
- public ABI;
- executable storage;
- typed executable local bindings.
For current executable contracts, represent amounts as integers and use posting helpers for accounting meaning.
Collections
Vec[T, MAX]
Map[K, V]
Map[K, V, MAX_ENTRIES]Use bounded collection forms for runtime safety. Sparse map and vector storage is supported.
Nested `Map` (`Map[K, Map[...], N]`) is not supported on the IR runtime (the backend used by IrContractInstance, the default for new contracts compiled via compile_contract/compile_contract_artifact and executed at runtime). The verifier rejects it at IrContractInstance::new(...) time with a clear "nested Map storage is not supported" error rather than letting it fail silently at read/write time. Instead, model the second key dimension with a composite/derived key in a single Map, e.g.:
storage:
beneficiary_category_funded: Map[Address, u128, 4096]
def derived_key(category: Address, beneficiary: Address) -> Address:
return derive_child_id(category, beneficiary, "cap_v1")or split the nested dimension into a child contract instead. The legacy ContractInstance evaluator (used by hand-written fixtures such as BasicToken/ERC20) does support nested Map — but new contracts should not rely on it, since the IR backend is the supported execution path going forward. See issue #54.
Structs
Struct[Name{field: Type, other: Type}]Structs group related fields under a single storage variable.
storage:
terms: Struct[LoanTerms{
principal: u128,
rate_ppm: u64,
active: bool
}]Access struct fields with .:
self.terms.principal
self.terms.active = TrueRestrictions:
- Structs are for storage and internal contract use only.
- Structs cannot appear in public entrypoint parameters or return values.
Money[...]inside a struct field is rejected by the compiler.
ABI Types
Public entrypoint parameters and returns should use currently executable types such as:
bool;- unsigned/signed integers;
Address;String;AssetId;Hash256;Percent.
Do not expose Money[...] in a public entrypoint.