Voltar para Documentação

Docs Técnicas

Artifacts And ABI

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

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

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

rust
pub struct ContractArtifact {
    pub contract_id: ContractId,
    pub version: u32,
    pub code_hash: CodeHash,
    pub imports_hash: ImportsHash,
    pub abi_hash: AbiHash,
    pub ir_hash: IrHash,
    pub storage_layout_hash: StorageLayoutHash,
    pub imports: Vec<ImportDecl>,
    pub entrypoints: Vec<EntryPointDesc>,
}

EntryPointDesc

rust
pub struct EntryPointDesc {
    pub name: String,
    pub selector: u32,
    pub kind: EntryPointKind,
    pub params: Vec<ParameterDesc>,
    pub returns: Vec<TypeDesc>,
    pub describe: Option<String>,
}

describe comes from @describe("...") on the entrypoint. It is author text for wallet and explorer UX; clients should combine it with simulation, receipts, and AI Audit facts before asking a user to sign.

EntryPointKind is the canonical execution class. The public source decorator for construction is @construct; internally this is represented as the init entrypoint kind so older @init sources remain compatible.

Hash Meaning

  • code_hash: source bytes;
  • imports_hash: canonical static import surface;
  • abi_hash: canonical entrypoint ABI;
  • ir_hash: canonical lowered IR;
  • storage_layout_hash: canonical storage layout.

Import order in source does not affect imports_hash, but adding, removing, renaming, or aliasing imports does. The current profile records imports for deterministic dependency identity; composition and code injection come later.

Selector

Selectors are the first four bytes of the SHA-256 hash of the canonical signature.

Ethereum JSON ABI

For wallet and SDK interoperability, atlas-trea can also export Ethereum JSON ABI items for the public TREA interface:

rust
let module = atlas_trea::parse_contract(source)?;
let abi = atlas_trea::ethereum_abi_for_module(&module)?;
let erc20 = atlas_trea::ethereum_erc20_abi();

ethereum_abi_for_module(&module) is the exact TREA surface. For ERC-20 tooling, ethereum_erc20_abi() emits the standard compatibility shape with uint256 amounts.

The Ethereum Adapter (GET /api/eth/abi/:artifact_id, POST /api/eth/call/:contract_id) uses this ABI to let ethers.js, viem, and wagmi call @view functions directly with standard Ethereum calldata — no custom client needed. See Ethereum Adapter for the full integration guide.