Voltar para Documentação

Docs Técnicas

Compile And Run Locally

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

O conteúdo abaixo vem das fontes técnicas do repositório e é prerenderizado no site para leitura direta por pessoas, crawlers e agentes.

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

rust
use atlas_trea::{
    compile_contract, parse_contract, verify_contract,
    ContractInstance, ExecutionContext, RuntimeValue,
};

let source = include_str!("counter.trea");

let module = parse_contract(source)?;
verify_contract(&module)?;

let compiled = compile_contract(source, 1)?;
println!("contract id: {:?}", compiled.artifact.contract_id);

let mut instance = ContractInstance::new(module)?;

let ctx = ExecutionContext {
    block_timestamp: 1_700_000_000,
    block_height: 1,
    caller: "nbex_sender".to_string(),
    asset: "BRL".to_string(),
    tx_id: "tx-1".to_string(),
    contract_id: "counter-demo".to_string(),
    family_id: "counter".to_string(),
    version_id: "v1".to_string(),
};

let output = instance.execute(
    "set",
    vec![RuntimeValue::Integer(10)],
    ctx,
)?;

println!("effects: {:?}", output.effects);
println!("cost: {:?}", output.cost);

Development Loop

  1. Parse source with parse_contract.
  2. Verify publishability with verify_contract.
  3. Compile and inspect CompiledContract.
  4. Execute locally with ContractInstance.
  5. Add fixture or integration tests.
  6. Publish through ledger transaction flow.

Compiler Output

compile_contract(...) returns:

  • canonical artifact;
  • lowered IR;
  • static cost receipt;
  • static cost proof;
  • storage layout descriptor;
  • safety profile;
  • optimizer report;
  • type-linearity report.