Voltar para Documentação

Docs Técnicas

Publish And Call Through AtlasDB

TREA contracts run through ledger transactions.

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

TREA contracts run through ledger transactions.

Lifecycle

  1. Publish a source artifact.
  2. Instantiate a contract from that artifact.
  3. Optionally accept a specific version as an actor.
  4. Update lifecycle to an executable state.
  5. Call entrypoints.

Publish

json
{
  "type": "PublishContractArtifact",
  "publish": {
    "artifact_id": "counter:v1",
    "family_id": "counter",
    "version_id": "v1",
    "source": "contract Counter:\n    storage:\n        value: u64 = 0\n...",
    "memo": "counter v1"
  }
}

Instantiate

json
{
  "type": "InstantiateContract",
  "instantiate": {
    "contract_id": "counter-demo",
    "artifact_id": "counter:v1",
    "admin": "nbex_admin"
  }
}

Activate

json
{
  "type": "UpdateContractLifecycle",
  "update": {
    "contract_id": "counter-demo",
    "lifecycle_state": "active",
    "reason": "ready"
  }
}

Call

json
{
  "type": "ContractCall",
  "call": {
    "contract_id": "counter-demo",
    "entrypoint": "set",
    "asset": "BRL",
    "args": [
      { "kind": "Integer", "value": "10" }
    ]
  }
}

Inline source in ContractCall is rejected. Publish and instantiate first.