{"id":47819289,"url":"https://github.com/xian-technology/xian-contracting","last_synced_at":"2026-05-14T19:01:59.187Z","repository":{"id":337150318,"uuid":"1126764688","full_name":"xian-technology/xian-contracting","owner":"xian-technology","description":"Contracting — Python-native smart contract engine powering the Xian blockchain","archived":false,"fork":false,"pushed_at":"2026-05-14T16:57:21.000Z","size":9250,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-05-14T17:40:01.023Z","etag":null,"topics":["blockchain","contracting","python","smart-contracts","virtual-machine","xian"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xian-technology.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-01-02T14:36:29.000Z","updated_at":"2026-05-14T16:57:25.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/xian-technology/xian-contracting","commit_stats":null,"previous_names":["xian-technology/xian-contracting"],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/xian-technology/xian-contracting","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xian-technology%2Fxian-contracting","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xian-technology%2Fxian-contracting/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xian-technology%2Fxian-contracting/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xian-technology%2Fxian-contracting/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xian-technology","download_url":"https://codeload.github.com/xian-technology/xian-contracting/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xian-technology%2Fxian-contracting/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33039250,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T13:14:54.681Z","status":"online","status_checked_at":"2026-05-14T02:00:06.663Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blockchain","contracting","python","smart-contracts","virtual-machine","xian"],"created_at":"2026-04-03T19:02:23.555Z","updated_at":"2026-05-14T19:01:59.181Z","avatar_url":"https://github.com/xian-technology.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# xian-contracting\n\n`xian-contracting` is the contract compiler, artifact builder, local test\nharness, and standard-library bridge for Xian. Network execution is defined by\nthe Xian VM (`xian_vm_v1`).\n\nThe published PyPI package is `xian-tech-contracting`. The import package\nremains `contracting`. Side packages under `packages/` (deterministic runtime\ntypes, accounts, fast-path validator, VM crates, zk tooling)\nare released independently and consumed by `xian-abci`, `xian-py`, and the\nnode runtime.\n\n## Package Shape\n\n```mermaid\nflowchart LR\n  Source[\"Authored contract source\"] --\u003e Compiler[\"Compiler and linter\"]\n  Compiler --\u003e Artifact[\"Deployment artifacts\"]\n  Artifact --\u003e VM[\"xian_vm_v1 execution target\"]\n  Artifact --\u003e Executor[\"Local harness\"]\n  Executor --\u003e Storage[\"Deterministic storage\"]\n  Executor --\u003e Stdlib[\"Stdlib bridge\"]\n  Executor --\u003e Events[\"LogEvent output\"]\n  Packages[\"Side packages\"] --\u003e VM\n  Packages --\u003e ZK[\"xian-zk\"]\n```\n\n## Quick Start\n\nInstall the package:\n\n```bash\nuv add xian-tech-contracting\n```\n\nOptional zk helpers are kept off the default install:\n\n```bash\nuv add 'xian-tech-contracting[zk]'\n```\n\nCompile deployment artifacts:\n\n```python\nfrom contracting.artifacts import build_contract_artifacts\n\nartifacts = build_contract_artifacts(\n    module_name=\"con_token\",\n    source=contract_source,\n)\n```\n\nRun a contract in the local harness:\n\n```python\nfrom contracting.local import ContractingClient\n\nclient = ContractingClient()\nclient.submit(name=\"con_token\", code=contract_source)\n\ntoken = client.get_contract_proxy(\"con_token\")\ntoken.transfer(amount=100, to=\"bob\")\n```\n\nUse the storage driver directly:\n\n```python\nfrom contracting.storage.driver import Driver\n\ndriver = Driver()\ndriver.set(\"example.key\", \"value\")\nprint(driver.get(\"example.key\"))\n```\n\n## Principles\n\n- **Contracts use Python syntax, but are not general Python.** Execution rules\n  are consensus-sensitive and intentionally narrower than the host language.\n- **Consensus parity comes first.** Metering, storage encoding, import\n  restrictions, and runtime helpers must stay version-aligned across all\n  validators.\n- **The Xian VM is the execution target.** The local harness is for contract\n  tests and developer ergonomics; the deployable artifact is source plus Xian\n  VM IR.\n- **Compiler and harness stay distinct.** SDKs and CLI deployment flows consume\n  deployment artifacts. The local harness may derive transient proxies for\n  testing, but those are not chain artifacts.\n- **Stay scoped.** Built-in helpers serve the execution model. They do not grow\n  into a general convenience framework.\n- **No node orchestration here.** Operator workflow, genesis distribution, and\n  container lifecycle belong in `xian-abci`, `xian-cli`, and `xian-stack`.\n- **Security-sensitive.** Favor small, well-tested changes. If a fix changes\n  execution semantics, add regression tests in the same change.\n\n## Key Directories\n\n- `src/contracting/` — compiler, artifacts, local harness, storage, and stdlib\n  bridge.\n  - `artifacts/` — public deployment artifact builder and validator.\n  - `compilation/` — parser, compiler, linter, and whitelist logic.\n  - `compiler/` — public compiler import surface.\n  - `execution/` — runtime, executor, module loading, and tracing.\n  - `local/` — high-level `ContractingClient` for local tests and tooling.\n  - `storage/` — drivers, ORM helpers, encoder, and LMDB-backed state.\n  - `contracts/` — package-local contract assets (e.g. the built-in submission\n    contract).\n  - `stdlib/` — contract-side standard-library bridge.\n- `packages/` — independently released sibling packages:\n  `xian-accounts`, `xian-compiler-core`, `xian-contract-tools`,\n  `xian-fastpath-core`,\n  `xian-runtime-types`, `xian-vm-core`, `xian-zk`.\n- `scripts/` — audit and fixture-generation tools used by VM/runtime work.\n- `tests/` — `unit/`, `integration/`, `security/`, `performance/` coverage.\n- `examples/` — notebook walk-throughs and a non-Jupyter validation script.\n- `docs/` — architecture, backlog, current-state notes, and active design drafts.\n\n## What This Runtime Covers\n\n- compilation and linting of contract source\n- local harness execution, metering, and import restrictions\n- storage drivers and encoding\n- contract-side runtime helpers (`stdlib` bridge)\n- speculative parallel batch execution primitives\n- native zero-knowledge verifier building blocks\n- Xian VM IR generation, validation, parity fixtures, and early native VM work\n\n## Validation\n\nDefault CI path (pure-Python, no Rust extensions):\n\n```bash\nuv sync --group dev\nuv run ruff check .\nuv run ruff format --check .\nuv run pytest --cov=contracting --cov-report=term-missing --cov-report=xml\n```\n\nThe default `pytest` config deselects tests marked `optional_native`; those\ntests require heavier Rust extension packages beyond the required compiler\ncore.\n\nNative / release CI path:\n\n```bash\n./scripts/validate-release.sh\n```\n\n`validate-release.sh` runs the default suite plus compiler-core, zk, and VM\nchecks, the WASM compiler package build, optional-native parity and fuzz\ncoverage, and the Rust-side package checks used by release CI. It is the gate\nfor tagging a release.\n\nIf you change metering, tracing, storage encoding, or import restrictions,\ntreat the change as consensus-sensitive and run the relevant `tests/security/`\nand `tests/integration/` paths explicitly.\n\n## Related Docs\n\n- [AGENTS.md](AGENTS.md) — repo-specific guidance for AI agents and contributors\n- [docs/README.md](docs/README.md) — index of internal design notes\n- [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) — major components and dependency direction\n- [docs/BACKLOG.md](docs/BACKLOG.md) — open work and follow-ups\n- [docs/COMPILER_RELEASE.md](docs/COMPILER_RELEASE.md) — compiler package validation and publish order\n- [docs/SAFETY_INVARIANTS.md](docs/SAFETY_INVARIANTS.md) — invariants the runtime must preserve\n- [docs/PARALLEL_EXECUTION.md](docs/PARALLEL_EXECUTION.md) — speculative parallel batch execution model\n- [docs/COMPILE_TIME_EXTENDS.md](docs/COMPILE_TIME_EXTENDS.md) — contract import / extends model\n- [docs/EXECUTION_BACKLOG.md](docs/EXECUTION_BACKLOG.md) — execution-engine follow-ups\n- [docs/SHIELDED_STATE_REDESIGN_V2.md](docs/SHIELDED_STATE_REDESIGN_V2.md) — shielded-state model\n- [docs/ZK_PRIVACY_OPTIMIZATION_PLAN.md](docs/ZK_PRIVACY_OPTIMIZATION_PLAN.md) — zk privacy roadmap\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxian-technology%2Fxian-contracting","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxian-technology%2Fxian-contracting","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxian-technology%2Fxian-contracting/lists"}