Skip to main content

Xian Network Python Contracting Engine

Project description

xian-contracting

xian-contracting is the contract compiler, artifact builder, local test harness, and standard-library bridge for Xian. Network execution is defined by the Xian VM (xian_vm_v1).

The published PyPI package is xian-tech-contracting. The import package remains contracting. Side packages under packages/ (deterministic runtime types, accounts, fast-path validator, VM crates, zk tooling) are released independently and consumed by xian-abci, xian-py, and the node runtime.

Package Shape

flowchart LR
  Source["Authored contract source"] --> Compiler["Compiler and linter"]
  Compiler --> Artifact["Deployment artifacts"]
  Artifact --> VM["xian_vm_v1 execution target"]
  Artifact --> Executor["Local harness"]
  Executor --> Storage["Deterministic storage"]
  Executor --> Stdlib["Stdlib bridge"]
  Executor --> Events["LogEvent output"]
  Packages["Side packages"] --> VM
  Packages --> ZK["xian-zk"]

Quick Start

Install the package:

uv add xian-tech-contracting

Optional zk helpers are kept off the default install:

uv add 'xian-tech-contracting[zk]'

Compile deployment artifacts:

from contracting.artifacts import build_contract_artifacts

artifacts = build_contract_artifacts(
    module_name="con_token",
    source=contract_source,
)

Run a contract in the local harness:

from contracting.local import ContractingClient

client = ContractingClient()
client.submit(contract_source, name="con_token")

token = client.get_contract_proxy("con_token")
token.transfer(amount=100, to="bob")

submit(...) accepts contract source as a string or a Python function whose body is the contract.

Use the storage driver directly:

from contracting.storage.driver import Driver

driver = Driver()
driver.set("example.key", "value")
print(driver.get("example.key"))

Principles

  • Contracts use Python syntax, but are not general Python. Execution rules are consensus-sensitive and intentionally narrower than the host language.
  • Consensus parity comes first. Metering, storage encoding, import restrictions, and runtime helpers must stay version-aligned across all validators.
  • The Xian VM is the execution target. The local harness is for contract tests and developer ergonomics; the deployable artifact is source plus Xian VM IR.
  • Compiler and harness stay distinct. SDKs and CLI deployment flows consume deployment artifacts. The local harness may derive transient proxies for testing, but those are not chain artifacts.
  • Stay scoped. Built-in helpers serve the execution model. They do not grow into a general convenience framework.
  • No node orchestration here. Operator workflow, genesis distribution, and container lifecycle belong in xian-abci, xian-cli, and xian-stack.
  • Security-sensitive. Favor small, well-tested changes. If a fix changes execution semantics, add regression tests in the same change.

Key Directories

  • src/contracting/ — compiler, artifacts, local harness, storage, and stdlib bridge.
    • artifacts/ — public deployment artifact builder and validator.
    • compilation/ — parser, compiler, linter, and whitelist logic.
    • compiler/ — public compiler import surface.
    • execution/ — runtime, executor, module loading, and tracing.
    • local/ — high-level ContractingClient for local tests and tooling.
    • storage/ — drivers, ORM helpers, encoder, and LMDB-backed state.
    • contracts/ — package-local contract assets (e.g. the built-in submission contract).
    • stdlib/ — contract-side standard-library bridge.
  • packages/ — independently released sibling packages: xian-accounts, xian-compiler-core, xian-fastpath-core, xian-runtime-types, xian-vm-core, xian-zk.
  • scripts/ — audit and fixture-generation tools used by VM/runtime work.
  • tests/unit/, integration/, security/, performance/ coverage.
  • examples/ — notebook walk-throughs and a non-Jupyter validation script.
  • docs/ — architecture, backlog, current-state notes, and active design drafts.

What This Runtime Covers

  • compilation and linting of contract source
  • local harness execution, metering, and import restrictions
  • storage drivers and encoding
  • contract-side runtime helpers (stdlib bridge)
  • speculative parallel batch execution primitives
  • native zero-knowledge verifier building blocks
  • Xian VM IR generation, validation, parity fixtures, and early native VM work

Validation

Default CI path (pure-Python, no Rust extensions):

uv sync --group dev
uv run ruff check .
uv run ruff format --check .
uv run pytest --cov=contracting --cov-report=term-missing --cov-report=xml

The default pytest config deselects tests marked optional_native; those tests require heavier Rust extension packages beyond the required compiler core.

Native / release CI path:

./scripts/validate-release.sh

validate-release.sh runs the default suite plus compiler-core, zk, and VM checks, the WASM compiler package build, optional-native parity and fuzz coverage, and the Rust-side package checks used by release CI. It is the gate for tagging a release.

If you change metering, tracing, storage encoding, or import restrictions, treat the change as consensus-sensitive and run the relevant tests/security/ and tests/integration/ paths explicitly.

Related Docs

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xian_tech_contracting-1.0.11b1.tar.gz (87.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xian_tech_contracting-1.0.11b1-py3-none-any.whl (99.8 kB view details)

Uploaded Python 3

File details

Details for the file xian_tech_contracting-1.0.11b1.tar.gz.

File metadata

  • Download URL: xian_tech_contracting-1.0.11b1.tar.gz
  • Upload date:
  • Size: 87.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for xian_tech_contracting-1.0.11b1.tar.gz
Algorithm Hash digest
SHA256 6dc19b91fbce9760034c2fb3166ff9d43c92d59db5add564a6e136755a9c8f4b
MD5 f83584b74218f6b67799a8ac54c57229
BLAKE2b-256 8687283afc79607ba0aecc57674e73d51091fd2744fc74604ce436d4c6be99b4

See more details on using hashes here.

Provenance

The following attestation bundles were made for xian_tech_contracting-1.0.11b1.tar.gz:

Publisher: release.yml on xian-technology/xian-contracting

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xian_tech_contracting-1.0.11b1-py3-none-any.whl.

File metadata

File hashes

Hashes for xian_tech_contracting-1.0.11b1-py3-none-any.whl
Algorithm Hash digest
SHA256 4d0aac4d4ec546e8cf03dc767dce103b384ef3b6f2c3d7d7de2470037c3002d9
MD5 cdf83bc3528b3862abfdf76d72af91a3
BLAKE2b-256 9db44d61fac979e4e6c8d04637d5a3172cc10bd92576e2760a915b903083a93c

See more details on using hashes here.

Provenance

The following attestation bundles were made for xian_tech_contracting-1.0.11b1-py3-none-any.whl:

Publisher: release.yml on xian-technology/xian-contracting

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page