{"id":20812266,"url":"https://github.com/xian-network/xian-contracting","last_synced_at":"2026-04-02T17:27:00.627Z","repository":{"id":213778734,"uuid":"733701043","full_name":"xian-network/xian-contracting","owner":"xian-network","description":"A subset of Python for developing smart contracts on the Xian Network","archived":false,"fork":false,"pushed_at":"2026-03-31T16:13:53.000Z","size":5757,"stargazers_count":200,"open_issues_count":33,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2026-03-31T18:11:50.757Z","etag":null,"topics":["blockchain","python","smart-contracts","xian"],"latest_commit_sha":null,"homepage":"https://linktr.ee/xiannetwork","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"Lamden/contracting","license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xian-network.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":null,"dco":null,"cla":null}},"created_at":"2023-12-19T23:36:33.000Z","updated_at":"2025-11-07T05:50:20.000Z","dependencies_parsed_at":"2024-06-07T13:37:56.618Z","dependency_job_id":"18f3409f-f6dd-49db-957d-b3839aec10e9","html_url":"https://github.com/xian-network/xian-contracting","commit_stats":null,"previous_names":["xianchain/contracting","xian-network/contracting"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/xian-network/xian-contracting","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xian-network%2Fxian-contracting","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xian-network%2Fxian-contracting/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xian-network%2Fxian-contracting/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xian-network%2Fxian-contracting/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xian-network","download_url":"https://codeload.github.com/xian-network/xian-contracting/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xian-network%2Fxian-contracting/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31311472,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T12:59:32.332Z","status":"ssl_error","status_checked_at":"2026-04-02T12:54:48.875Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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","python","smart-contracts","xian"],"created_at":"2024-11-17T20:51:41.117Z","updated_at":"2026-04-02T17:27:00.578Z","avatar_url":"https://github.com/xian-network.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Xian Contracting\n\nXian Contracting is a Python-based smart contract development and execution framework. Unlike traditional blockchain platforms like Ethereum, Xian Contracting leverages Python's VM to create a more accessible and familiar environment for developers to write smart contracts.\n\n## Features\n\n- **Python-Native**: Write smart contracts in standard Python with some additional decorators and constructs\n- **Storage System**: Built-in ORM-like system with `Variable` and `Hash` data structures\n- **Runtime Security**: Secure execution environment with memory and computation limitations\n- **Metering System**: Built-in computation metering to prevent infinite loops and resource abuse\n- **Event System**: Built-in logging and event system for contract state changes\n- **Import Controls**: Secure import system that prevents access to dangerous system modules\n\n## Installation\n\n```bash\npip install xian-contracting\n```\n\n## Quick Start\n\nHere's a complete token contract example with approval system:\n\n```python\ndef token_contract():\n    balances = Hash()\n    owner = Variable()\n    \n    @construct\n    def seed():\n       owner.set(ctx.caller)\n    \n    @export\n    def approve(amount: float, to: str):\n       assert amount \u003e 0, 'Cannot send negative balances.'\n       balances[ctx.caller, to] += amount\n    \n    @export\n    def transfer_from(amount: float, to: str, main_account: str):\n        approved = allowances[main_account, ctx.caller]\n    \n        assert amount \u003e 0, 'Cannot send negative balances!'\n        assert approved \u003e= amount, f'You approved {approved} but need {amount}'\n        assert balances[main_account] \u003e= amount, 'Not enough tokens to send!'\n    \n        allowances[main_account, ctx.caller] -= amount\n        balances[main_account] -= amount\n        balances[to] += amount\n    \n    @export\n    def transfer(amount: float, to: str):\n       assert amount \u003e 0, 'Cannot send negative balances.'\n       assert balances[ctx.caller] \u003e= amount, 'Not enough coins to send.'\n    \n       balances[ctx.caller] -= amount\n       balances[to] += amount\n    \n    @export\n    def mint(to, amount):\n       assert ctx.caller == owner.get(), 'Only the original contract author can mint!'\n       balances[to] += amount\n```\n\n## Core Concepts\n\n### Storage Types\n\n- **Variable**: Single-value storage\n  ```python\n  counter = Variable()\n  counter.set(0)  # Set value\n  current = counter.get()  # Get value\n  ```\n\n- **Hash**: Key-value storage with support for complex and multi-level keys\n  ```python\n  balances = Hash()\n  # Single-level key\n  balances['alice'] = 100\n  alice_balance = balances['alice']\n  \n  # Multi-level keys for complex relationships\n  balances['alice', 'bob'] = 50  # e.g., alice approves bob to spend 50 tokens\n  approved_amount = balances['alice', 'bob']  # Get the approved amount\n  \n  # You can use up to 16 dimensions in key tuples\n  data['user', 'preferences', 'theme'] = 'dark'\n  ```\n\n### Contract Decorators\n\n- **@construct**: Initializes contract state (can only be called once)\n  ```python\n  @construct\n  def seed():\n      owner.set(ctx.caller)\n  ```\n\n- **@export**: Makes function callable from outside the contract\n  ```python\n  @export\n  def increment(amount: int):\n      counter.set(counter.get() + amount)\n  ```\n\n### Contract Context\n\nThe `ctx` object provides important runtime information:\n\n- `ctx.caller`: Address of the account calling the contract\n- `ctx.this`: Current contract's address\n- `ctx.signer`: Original transaction signer\n- `ctx.owner`: Contract owner's address\n\n## Using the ContractingClient\n\nThe `ContractingClient` class is your main interface for deploying and interacting with contracts:\n\n```python\nfrom contracting.client import ContractingClient\n\n# Initialize the client\nclient = ContractingClient()\n\n# Submit a contract\nwith open('token.py', 'r') as f:\n    contract = f.read()\n    \nclient.submit(name='con_token', code=contract)\n\n# Get contract instance\ntoken = client.get_contract('con_token')\n\n# Call contract methods\ntoken.transfer(amount=100, to='bob')\n```\n\n## Storage Driver\n\nThe framework includes a powerful storage system:\n\n```python\nfrom contracting.storage.driver import Driver\n\ndriver = Driver()\n\n# Direct storage operations\ndriver.set('key', 'value')\ndriver.get('key')\n\n# Contract storage\ndriver.set_contract(name='contract_name', code=contract_code)\ndriver.get_contract('contract_name')\n```\n\n## Event System\n\nContracts can emit events which can be tracked by external systems:\n\n```python\ndef token_contract():\n    transfer_event = LogEvent(\n        'transfer',\n        {\n            'sender': {'type': str, 'idx': True},\n            'receiver': {'type': str, 'idx': True},\n            'amount': {'type': float}\n        }\n    )\n\n    @export\n    def transfer(amount: float, to: str):\n        # ... transfer logic ...\n        \n        # Emit event\n        transfer_event({\n            'sender': ctx.caller,\n            'receiver': to,\n            'amount': amount\n        })\n```\n\n## Security Features\n\n- Restricted imports to prevent malicious code execution\n- Memory usage tracking and limitations\n- Computation metering to prevent infinite loops\n- Secure runtime environment\n- Type checking and validation\n- Private method protection\n\n## Development and Testing\n\nWhen developing contracts, you can use the linter to check for common issues:\n\n```python\nfrom contracting.client import ContractingClient\n\nclient = ContractingClient()\nviolations = client.lint(contract_code)\n```\n\n## License\n\nThis project is licensed under the Creative Commons Attribution‑NonCommercial 4.0 International - see the [LICENSE](LICENSE) file for details.\nNon‑commercial use only.  See LICENSE for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxian-network%2Fxian-contracting","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxian-network%2Fxian-contracting","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxian-network%2Fxian-contracting/lists"}