Voltar para Home

Docs Técnicas

Base
Técnica

Um mapa crate por crate do workspace Rust atual.

Esta área transforma a documentação técnica em uma superfície navegável dentro do atlas-brand-site, mantendo as fontes canônicas em docs/rust-v2 e docs/trea-book.

A interface do site é multilíngue, mas o conteúdo técnico continua sendo mantido na linguagem original da equipe para reduzir drift entre versões.

Cobertura

Docs

87

Camadas

4

Status

v1

Método

Fonte canônica primeiro

Cada página é renderizada a partir dos documentos mantidos no repositório, reduzindo drift entre site, código, linguagem TREA e runtime.

docs/rust-v2 + docs/trea-book

TREA Book

Livro TREA

Linguagem, contratos, integrações, exemplos, segurança e runtime TREA indexados a partir de docs/trea-book.

TREA Book

The TREA Book

TREA is the AtlasDB contract language for deterministic financial workflows.

4 seçõesAbrir

TREA Book

What Is TREA?

TREA is a deterministic contract language for AtlasDB.

3 seçõesAbrir

TREA Book

A Simple Contract

This contract stores a single counter.

5 seçõesAbrir

TREA Book

Compile And Run Locally

Use atlas-trea directly for tests, fixtures, and development tooling.

2 seçõesAbrir

TREA Book

Publish And Call Through AtlasDB

TREA contracts run through ledger transactions.

5 seçõesAbrir

TREA Book

Source Layout

A TREA source file contains one contract and may start with static imports.

8 seçõesAbrir

TREA Book

Types

TREA is statically typed.

5 seçõesAbrir

TREA Book

Storage

Storage is contract-local persistent state.

6 seçõesAbrir

TREA Book

Expressions

TREA supports a deliberately small expression set.

8 seçõesAbrir

TREA Book

Functions And Entry Points

Every callable function is a contract entrypoint.

9 seçõesAbrir

TREA Book

Construction And Address Safety

TREA contracts use @construct for one-shot construction. This is the constructor model: initialize required state once, then expose the normal @tx and @view entrypoints.

3 seçõesAbrir

TREA Book

Static Composition

TREA contracts can inherit storage and behaviour from reusable base modules. Composition is resolved entirely at compile time — there is no virtual dispatch or runtime module loading.

7 seçõesAbrir

TREA Book

Standard Library

TREA ships built-in modules under the std namespace, grouped by product domain. They are published on-chain as part of the platform bootstrap and are available to every contract without any separate deployment step.

22 seçõesAbrir

TREA Book

Runtime Context

The runtime context is available as ctx.

6 seçõesAbrir

TREA Book

Intrinsics

Intrinsics are built-in functions known to the verifier and runtime.

12 seçõesAbrir

TREA Book

Accounting Effects

TREA separates business state from ledger accounting.

6 seçõesAbrir

TREA Book

Loops And Bounds

TREA supports bounded loops only.

3 seçõesAbrir

TREA Book

Unsupported Features

This page documents features outside the current executable profile.

3 seçõesAbrir

TREA Book

Wallet Loan

This is the canonical loan example used by the current test fixtures.

5 seçõesAbrir

TREA Book

RWA Product Patterns

These examples show how the Phase 12 stdlib modules compose RWA registration, tokenized ownership, funds, and credit products.

3 seçõesAbrir

TREA Book

Spending Vaults And Card Authorization

TREA models card-like spending as a contract-controlled authorization, not as a card key controlling the user's main wallet.

4 seçõesAbrir

TREA Book

Sparse Storage

Sparse maps and vectors are useful for bounded contract-local business data.

2 seçõesAbrir

TREA Book

Corrections

Corrections are first-class accounting events.

6 seçõesAbrir

TREA Book

Versioned Contract Flow

TREA contract execution is artifact-based.

7 seçõesAbrir

TREA Book

Financial Message Profiles

TREA Financial Message Profiles are executable contracts that model institutional financial instructions. They are not SWIFT parsers or message adapters — they execute typed financial intent with balance effects, lifecycle governance, and auditable receipts.

10 seçõesAbrir

TREA Book

Insurance Contracts

TREA ships three ready-to-use insurance contract templates for institutional product flows:

7 seçõesAbrir

TREA Book

Hedge Contracts

TREA ships two ready-to-use hedge contract templates that settle FX derivative positions whose terms were priced off-chain by QuoteNet:

8 seçõesAbrir

TREA Book

Consortium Agreement

TREA ships a ConsortiumAgreement template (contracts/products/consortium_agreement.trea) modeling a Brazilian-style *consórcio*: a group of participants who pool periodic contributions into a shared reserve, and take turns receiving the quota's credit value either by lottery (*sorteio*) or by bid (*lance*).

7 seçõesAbrir

TREA Book

Category Cards

TREA ships a category-card pattern for products where an institution funds a beneficiary, but the beneficiary can only use the value inside declared policy categories such as food, mobility, health, education, cashback, or travel.

5 seçõesAbrir

TREA Book

Pension Plans

TREA includes two pension templates for long-term accumulation products:

5 seçõesAbrir

TREA Book

Capitalization Plans

contracts/products/capitalization_plan.trea models a capitalization plan (plano de capitalização): periodic or one-off contributions into a per-participant reserve, eligibility for a periodic lottery drawing (sorteio), and maturity/redemption.

6 seçõesAbrir

TREA Book

Surety Agreement

contracts/products/surety_agreement.trea models a fiança contratual ou financeira — distinct from a seguro garantia (parametric/insurance-style guarantee). The fiador (surety) assumes the obligation owed to the beneficiary/credor on behalf of the debtor (afiançado). After the fiador pays a claim, a right of regress (direito de regresso) against the debtor is created and tracked on-chain, recoverable partially or in full.

6 seçõesAbrir

TREA Book

Surety Insurance Policy

contracts/products/surety_insurance_policy.trea models a seguro garantia (performance bond / garantia contratual) — a specialization sitting between std.profile.GuaranteeLifecycle and the insurance templates in insurance_parametric.trea. The insurer (seguradora) underwrites the policyholder's (tomador) obligation toward the beneficiary/insured (segurado), in exchange for a premium and a reserve/capacity it constitutes for the guaranteed limit. Unlike SuretyAgreement (a pure fiança with collateral-in-escrow), this contract is accounted through the insurance posting lines (post(insurance.*_lines(...))), and after indemnification it creates an explicit right of subrogation against the policyholder, tracked separately from the original guaranteed obligation.

8 seçõesAbrir

TREA Book

Escrow Agreement

std.asset.EscrowAgreement[Asset] models conditional custody: one party deposits funds into an escrow account, and release or refund happens only through the contract's lifecycle rules.

4 seçõesAbrir

TREA Book

Credit Products

TREA includes several credit contracts that share the same core idea: the contract stores the product lifecycle, while ledger posting helpers describe the economic event.

5 seçõesAbrir

TREA Book

Asset Primitives

The asset primitives are lower-level than the product demos. They are the building blocks used when a contract needs ledger-aware value, ownership, or custody without inheriting a full product lifecycle.

5 seçõesAbrir

TREA Book

Admin Patterns

TREA standardizes a small set of administrative modules so product contracts do not invent a different owner, role, or pause shape every time.

4 seçõesAbrir

TREA Book

Institution Token

A fungible token issued by a financial institution. Combines BasicToken (supply tracking) and Ownable (single-owner access control) via static composition.

3 seçõesAbrir

TREA Book

Pausable Institution Token

Extends the institution token with an emergency pause switch. Mint and transfer are blocked while the contract is paused; the owner can pause and unpause at will.

3 seçõesAbrir

TREA Book

Multisig Vault

A treasury that requires M-of-N signer approvals before any transfer executes. Standalone contract — no composition.

4 seçõesAbrir

TREA Book

Simple Loan

A minimal loan lifecycle contract: originate, repay in instalments, declare default. Composes Roles for a separate admin address.

4 seçõesAbrir

TREA Book

KYC-Gated Token

A token where both sender and recipient must be individually whitelisted before any transfer or mint can occur. Composes BasicToken and Ownable. Includes optional per-transfer and daily-mint limits.

5 seçõesAbrir

TREA Book

Rust API

The atlas-trea crate exposes parser, verifier, compiler, runtime, authoring, governance, product, economic, and institutional APIs.

12 seçõesAbrir

TREA Book

On-Chain Module Registry

Base modules (stdlib and custom) live on-chain as regular contract artifacts. A child contract resolves its impl dependencies against the registry at ContractCall time.

7 seçõesAbrir

TREA Book

Ledger Transactions

TREA integration uses AtlasDB transaction payloads.

8 seçõesAbrir

TREA Book

REST Submission

AtlasDB nodes accept signed transactions over REST.

4 seçõesAbrir

TREA Book

Artifacts And ABI

Artifacts bind source, ABI, IR, and storage layout to canonical hashes.

4 seçõesAbrir

TREA Book

ERC-20 Interoperability

TREA supports an ERC-20-style base token through the BasicToken fixture.

2 seçõesAbrir

TREA Book

Ethereum Adapter

The Ethereum adapter lets any dApp built with ethers.js, viem, wagmi, or web3.js talk to a TREA contract without knowing it's TREA underneath. It speaks the same ABI language that Ethereum established as the industry standard.

6 seçõesAbrir

TREA Book

Contract Events

TREA contracts emit events via emit EventName(arg1, arg2, ...). After a ContractCall transaction is committed, the emitted events are available through the events endpoint.

5 seçõesAbrir

TREA Book

Simulation (Dry-Run)

The simulation endpoint lets you execute a contract entrypoint without committing any effects to the ledger. Wallets, dashboards, and audit tools use it to preview return values, accounting effects, emitted events, and execution cost before the user signs and submits the real transaction.

6 seçõesAbrir

TREA Book

Contract Execution Receipts

Every successful ContractCall transaction produces a ContractExecutionReceipt — a persistent record stored in redb that survives node restarts. Receipts capture what happened inside the execution: which entrypoint ran, what arguments were passed, what the contract returned, the effects summary, and the cost breakdown.

4 seçõesAbrir

TREA Book

Operation Kind Catalog

Every posting emitted by a TREA contract carries an operation kind that identifies the economic nature of the entry. Wallets, dashboards, and audit tools use this to classify movements without re-parsing contract source.

4 seçõesAbrir

TREA Book

Lifecycle And Version Binding

TREA uses explicit lifecycle and version acceptance.

4 seçõesAbrir

TREA Book

KYC And Private Sharing

TREA contracts can make compliance decisions without receiving documents, personal data, or validator-only evidence. The ledger stores a minimal public KYC state, and detailed disclosure happens through a private validator channel authorized by the wallet.

4 seçõesAbrir

TREA Book

AI Audit Predeploy

AI Audit is a predeploy gate for TREA contracts. It combines deterministic compiler facts with an optional LLM explanation, then binds the report to the published artifact.

4 seçõesAbrir

TREA Book

Operational Interoperability

Operational interoperability lets external systems use TREA contracts without turning contracts into HTTP clients. The chain exposes a plug; external systems present signed envelopes and signed transactions.

4 seçõesAbrir

TREA Book

On-Demand Contract Factory

The on-demand factory pattern lets an institution publish a governed product template and create one child contract per approved customer request.

6 seçõesAbrir

TREA Book

TREA CLI (`trea`)

trea is the project CLI for TREA contracts — compile, deploy, call, and inspect contracts on any AtlasDB node without writing transaction payloads by hand.

14 seçõesAbrir

TREA Book

Compiler Reports

compile_contract(...) returns a rich CompiledContract.

3 seçõesAbrir

TREA Book

Authoring Diagnostics

Use authoring diagnostics while writing contracts.

1 seçõesAbrir

TREA Book

Testing Contracts

Recommended test layers:

4 seçõesAbrir

TREA Book

Parser And Verifier

The parser converts source into ContractModule.

4 seçõesAbrir

TREA Book

IR And Runtime

TREA has both AST runtime support and direct IR runtime support for the currently lowered executable subset.

5 seçõesAbrir

TREA Book

Storage Encoding

Storage encoding is deterministic and sparse.

4 seçõesAbrir

TREA Book

Cost Model

TREA has static and runtime cost surfaces.

3 seçõesAbrir

TREA Book

Authoring Checklist

Before publishing a contract:

2 seçõesAbrir

TREA Book

Accounting Safety

TREA accounting safety comes from explicit journal intent plus ledger validation.

5 seçõesAbrir

TREA Book

Common Pitfalls

Bad:

7 seçõesAbrir

TREA Book

Terminology

This book uses the following terms consistently.

8 seçõesAbrir

TREA Book

Syntax Reference

``python @describe("optional contract description") contract Name: ``

9 seçõesAbrir

TREA Book

Intrinsic Reference

All intrinsics are built into the TREA runtime. You cannot shadow them with function definitions. Collection intrinsics (vec_*, map_*) return new values — assign the result back to the storage field to persist the change.

20 seçõesAbrir

TREA Book

Transaction Payload Reference

``json { "kind": "Bool", "value": true } { "kind": "Integer", "value": "123" } { "kind": "Address", "value": "nbex..." } { "kind": "Text", "value": "hello" } ``

7 seçõesAbrir

TREA Book

Error And Diagnostic Surfaces

Errors surface in two prefix families: MP (mempool / pre-ledger validation) and LE (ledger execution). The prefix tells you which component rejected the transaction — you do not need to reach the ledger to get an MP error.

4 seçõesAbrir

Domínio

Crates de Domínio

Tipos, contratos e regras centrais que definem a linguagem do protocolo.

Infraestrutura

Crates de Infraestrutura

Ledger, mempool, rede e consenso que sustentam a execução do sistema.

Aplicação

Crates de Aplicação

Entradas operacionais, serviços e binários que expõem a blockchain ao mundo real.

Aplicação

atlas-node

atlas-node is the main application/runtime package of the Rust workspace. It is the place where atlas-consensus, atlas-ledger, atlas-mempool, and atlas-p2p are assembled into a running node process with networking, block production, state sync, public APIs, telemetry, and operator-facing setup flows.

12 seçõesAbrir

Aplicação

atlas-ingress

atlas-ingress is a small public REST ingress/proxy that sits in front of atlas-node's REST API. Its job is to expose a tightly allowlisted public surface for reads, transaction submission, and SSE events without exposing the full node API directly.

14 seçõesAbrir

Aplicação

atlas-node-admin

atlas-node-admin is a library-only admin/backoffice API crate that atlas-node can embed when the demo-admin-apis feature is enabled. It exposes admin routes for account and institution operations, KYC issuance and registration helpers, and a workflow system for KYC/alias review backed by SQLite plus filesystem-stored evidence blobs.

16 seçõesAbrir

Aplicação

atlas-wallet

atlas-wallet is a hybrid package that combines three roles:

14 seçõesAbrir

Aplicação

atlas-keygen

atlas-keygen is a very small operational CLI for inspecting libp2p node keypair files. Today it is effectively an extraction tool, not a full key-management suite.

11 seçõesAbrir

Aplicação

atlas-airdrop

atlas-airdrop is a standalone HTTP faucet service that funds a destination wallet by submitting a small batch of signed transactions to the node API. It owns public request ingress, config validation, rate limiting, upstream node interaction, and Prometheus telemetry.

15 seçõesAbrir