Skip to main content

xian-contracting

xian-contracting is the contract compiler, source/artifact utility layer, 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["Offline artifacts"]
  Compiler --> VM["xian_vm_v1 execution target"]
  Source --> 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 source or build artifacts for offline inspection:

from contracting.artifacts import build_contract_artifacts, compile_contract_source

compiled = compile_contract_source(
    module_name="con_token",
    source=contract_source,
)
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. Validators accept cleartext source and derive canonical Xian VM IR themselves before persisting deployed state.
  • Compiler and harness stay distinct. SDKs and CLI deployment flows submit source. Offline artifacts are useful for diagnostics and CI, but are not the public deployment payload.
  • Compilation is bounded. The Rust compiler admits at most 128 KiB source, 50,000 syntax nodes, syntax depth 64, 100,000 tokens total, 4,096 tokens on one logical line, 1 MiB of canonical IR JSON, and 512 contract-handle inference passes. Every binding returns the same xian.limit.* diagnostic.
  • 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 source compiler, 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.

Metadata

Release files for xian-tech-contracting 1.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xian-tech-contracting 1.1.3
File Size Uploaded Provenance Actions
xian_tech_contracting-1.1.3.tar.gz 88.2 kB With provenance Details for xian_tech_contracting-1.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for xian-tech-contracting 1.1.3
File Interpreter ABI Platform Actions
xian_tech_contracting-1.1.3-py3-none-any.whl Python 3 none any Details for xian_tech_contracting-1.1.3-py3-none-any.whl

Total release size: 189.0 kB

Release files / xian_tech_contracting-1.1.3.tar.gz

Download URL xian_tech_contracting-1.1.3.tar.gz
Size 88.2 kB
Tags Source
SHA-256 checksum
How to use checksums
05e32ec68d26c0c6615729f132a4a49069660b20a43bc6baa144be5dcd3ac157
BLAKE2b-256 checksum
How to use checksums
e8ca0f4ff051875be9ac0877078fb5a3a0b2912b6105589824983b3d80630f17
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.

Transparency log

Release files / xian_tech_contracting-1.1.3-py3-none-any.whl

Download URL xian_tech_contracting-1.1.3-py3-none-any.whl
Size 100.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bfb431e0dd9267c38697eea11d09621e78c74a618f0c8361b720a7f3b23201f5
BLAKE2b-256 checksum
How to use checksums
6ac05472889c87e9d742ee9c3e96cebb5e402e40309a4419b944be1e36e78d3e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.

Transparency log

Security for xian-tech-contracting 1.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for xian_tech_contracting-1.1.3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page