{"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":"en","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,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[]}