Voltar para Documentação

Docs Técnicas

Versioned Contract Flow

TREA contract execution is artifact-based.

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 contract execution is artifact-based.

This flow separates executable code selection from persisted contract state.

Publish V1

json
{
  "type": "PublishContractArtifact",
  "publish": {
    "artifact_id": "loan:v1",
    "family_id": "loan",
    "version_id": "v1",
    "source": "contract WalletLoan: ..."
  }
}

Instantiate Contract

json
{
  "type": "InstantiateContract",
  "instantiate": {
    "contract_id": "loan-001",
    "artifact_id": "loan:v1",
    "admin": "nbex_admin"
  }
}

The instance now has:

  • a default artifact;
  • persisted storage;
  • lifecycle state;
  • optional admin and accepted version bindings.

Publish V2

json
{
  "type": "PublishContractArtifact",
  "publish": {
    "artifact_id": "loan:v2",
    "family_id": "loan",
    "version_id": "v2",
    "source": "contract WalletLoan: ..."
  }
}

Accept V2

json
{
  "type": "AcceptContractVersion",
  "accept": {
    "contract_id": "loan-001",
    "artifact_id": "loan:v2",
    "role": "borrower"
  }
}

Resolution Rule

Calls resolve as:

  1. caller's accepted artifact for the contract family, if present;
  2. otherwise the instance default artifact.

Storage layout compatibility is checked before accepting a version.

Step-By-Step Behavior

  1. PublishContractArtifact stores immutable source and canonical artifact metadata.
  2. InstantiateContract creates a contract instance bound to the published family.
  3. A later PublishContractArtifact can add a new artifact version to the same family.
  4. AcceptContractVersion records an actor-specific execution choice.
  5. ContractCall resolves executable code from accepted version first, then falls back to the instance default artifact.

Important Boundary

The accepted version changes which artifact a caller executes.

It does not create a new contract instance and does not create a separate storage namespace.

The same contract instance storage remains in place while executable artifact selection changes by actor.