{"id":6562,"library":"chia-rs","title":"Chia-rs","description":"The `chia-rs` library provides high-performance Python bindings for core Chia blockchain primitives implemented in Rust, including consensus rules, protocol message types, and cryptography components. It offers efficient operations crucial for Chia development. The current version is 0.42.0. The library maintains a frequent release cadence, often incorporating updates related to Chia blockchain soft forks and performance enhancements.","status":"active","version":"0.42.0","language":"python","source_language":"en","source_url":"https://github.com/Chia-Network/chia_rs","tags":["blockchain","chia","cryptocurrency","rust","performance","consensus","bls","clvm"],"install":[{"cmd":"pip install chia-rs","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"note":"Represents a point on the G1 elliptic curve, often used for public keys in BLS signatures.","symbol":"G1Element","correct":"from chia_rs import G1Element"},{"note":"Represents a point on the G2 elliptic curve, often used for signatures in BLS.","symbol":"G2Element","correct":"from chia_rs import G2Element"},{"note":"Represents a BLS private key for cryptographic operations.","symbol":"PrivateKey","correct":"from chia_rs import PrivateKey"},{"note":"Represents a CLVM program, essential for Chia's smart transactions (Chialisp).","symbol":"Program","correct":"from chia_rs import Program"}],"quickstart":{"code":"import os\nfrom chia_rs import PrivateKey, G1Element, G2Element\n\n# Generate a random private key (seed should be truly random in production)\nprivate_key = PrivateKey.from_seed(os.urandom(32))\nprint(f\"Private Key (G1 Element Hex): {private_key.get_g1().serialize().hex()}\")\n\n# Derive the corresponding public key (G1Element)\npublic_key = private_key.get_g1()\nprint(f\"Public Key (G1Element Hex): {public_key.serialize().hex()}\")\n\n# Sign a message\nmessage = b\"Hello, Chia blockchain!\"\nsignature = private_key.sign(message)\nprint(f\"Signature (G2Element Hex): {signature.serialize().hex()}\")\n\n# Verify the signature\nis_valid = signature.verify(public_key, message)\nprint(f\"Signature Valid: {is_valid}\")","lang":"python","description":"This quickstart demonstrates how to generate a BLS private key, derive its public key, sign a message, and verify the signature using the `chia-rs` library. This showcases fundamental cryptographic operations built into `chia-rs`."},"warnings":[{"fix":"If upgrading from an earlier version, remove the `allocator` argument from calls to `run_block_generator*` and instead retrieve it from the function's return value.","message":"The `run_block_generator*` functions underwent a breaking change in version 0.39.0, where the `allocator` argument was removed and is now returned directly by the function.","severity":"breaking","affected_versions":">=0.39.0"},{"fix":"Always align your `chia-rs` version with the recommended version for the Chia blockchain network you are interacting with. Refer to the official Chia-Network/chia-blockchain changelog and release notes for compatibility details and mandatory soft fork upgrade deadlines.","message":"Versions of `chia-rs` are tightly coupled with specific Chia blockchain soft fork rules and consensus logic. Using an outdated `chia-rs` version with a newer blockchain (or vice versa) can lead to incorrect consensus validation, transaction processing, and network incompatibility. This is critical for changes introduced in versions like 0.40.0, 0.41.0, and 0.42.0, which implement new 'cost per spend' and 'spend limits' rules.","severity":"gotcha","affected_versions":"All versions, especially critical for >=0.40.0"},{"fix":"Upgrade your Python environment to 3.9 or newer. Python 3.10+ is often used in recent Chia ecosystem projects.","message":"While `chia-rs` is a Rust-backed library, its primary consumer, the `chia-blockchain` project, officially dropped support for Python 3.8. It is strongly recommended to use Python 3.9 or higher for any development involving `chia-rs` to ensure broad ecosystem compatibility and avoid potential issues.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'0.42.0':44 'bind':14 'blockchain':18,58,64 'bls':70 'cadenc':51 'chia':2,6,17,38,57,65 'chia-r':1,5 'clvm':71 'compon':31 'consensus':24,69 'core':16 'crucial':36 'cryptocurr':66 'cryptographi':30 'current':41 'develop':39 'effici':34 'enhanc':63 'fork':60 'frequent':49 'high':11 'high-perform':10 'implement':20 'includ':23 'incorpor':53 'librari':8,46 'maintain':47 'messag':27 'offer':33 'often':52 'oper':35 'perform':12,62,68 'primit':19 'protocol':26 'provid':9 'python':13 'relat':55 'releas':50 'rs':3,7 'rule':25 'rust':22,67 'soft':59 'type':28 'updat':54 'version':42","created_at":"2026-04-15T18:33:13.458198+00:00","updated_at":"2026-04-16T02:02:28.379373+00:00","problems":[{"fix":"Ensure `chia-rs` is installed in your active Python environment. If using a virtual environment, activate it. If the package was not installed or corrupted, reinstall it: `pip install chia-rs`.","cause":"The Python interpreter cannot find the 'chia_rs' package, usually because it was not installed correctly, the virtual environment is not activated, or the installation path is not in the Python search path.","error":"ModuleNotFoundError: No module named 'chia_rs'"},{"fix":"Install the Rust toolchain: `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh`. Ensure `maturin` is installed (`pip install maturin`). If the error persists, check for system-level dependencies or platform-specific build instructions. Sometimes, using a pre-built wheel (if available for your OS/architecture/Python version) or upgrading `pip`/`setuptools` can help.","cause":"This error occurs during installation when `pip` attempts to build the `chia-rs` Python wheel from source, but the underlying Rust compilation process (handled by `maturin` and `cargo`) fails. This can be due to a missing Rust toolchain, incorrect environment setup, or platform-specific build issues.","error":"error: subprocess-exited-with-error × Preparing metadata (pyproject.toml) did not run successfully. │ exit code: 1"},{"fix":"Reinstall `clvm_rs` to ensure compatibility, often by upgrading or reinstalling `chia-blockchain` itself, which manages its dependencies: `pip install --upgrade chia-blockchain` or `pip install --force-reinstall clvm_rs`.","cause":"This specific import error indicates a version mismatch or a corrupted installation of the `clvm_rs` library, which is a Rust-backed dependency within the Chia ecosystem. The Python bindings for `deserialize_and_run_program2` are either missing or incompatible with the installed `chia-blockchain` version.","error":"ImportError: cannot import name 'deserialize_and_run_program2' from 'clvm_rs'"},{"fix":"Ensure your Python version and operating system are officially supported. Try updating `pip` (`pip install --upgrade pip`). If a specific version is required, try installing a slightly older or newer version if it has pre-built wheels. In some cases, you may need to build from source, which requires the Rust toolchain to be installed, but if pre-built distributions are simply missing, building from source is the only option, which may be what causes the 'subprocess-exited-with-error' described above if environment is not correctly set up for compilation.","cause":"This error indicates that `pip` could not find a pre-built binary wheel for the specified version of `clvm-rs` (or `chia-rs`) that matches your operating system, architecture, and Python version. This often happens on less common platforms or when Python versions are very new.","error":"ERROR: Could not find a version that satisfies the requirement clvm-rs==X.X.X (from chia-blockchain) (from versions: ...)"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.45.0","cli_name":"","cli_version":null,"type":"library","homepage":"https://www.chia.net","github":"https://github.com/Chia-Network/chia_rs","docs":null,"changelog":null,"pypi":"https://pypi.org/project/chia-rs/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["database","auth-security","serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-28","install_tag":null}}