chia-puzzles-py

raw JSON →
0.20.3 verified Mon Apr 27 auth: no python

A collection of the currently deployed ChiaLisp puzzles used in Chia blockchain, including standard transactions, CATs, DIDs, and other puzzle types. Version 0.20.3 supports Python >=3.8,<4.0.

pip install chia-puzzles-py
error ModuleNotFoundError: No module named 'chia.puzzles'
cause The package is not installed or the import path is wrong.
fix
Install via 'pip install chia-puzzles-py'. Ensure you are using the correct import prefix 'chia.puzzles' (not 'puzzles' alone).
error AttributeError: module 'chia.puzzles' has no attribute 'p2_delegated_puzzle_or_hidden_puzzle'
cause Direct import of 'chia.puzzles' fails because the module is a package; you must import the submodule explicitly.
fix
Use 'from chia.puzzles.p2_delegated_puzzle_or_hidden_puzzle import ...'
error clvm_tools.errors.CLVMError: unknown puzzle
cause Attempting to load a .clvm file that does not exist in the bundled puzzles.
fix
Verify the puzzle name. Use 'load_clvm' with the exact filename (without path). Available puzzles include 'p2_delegated_puzzle_or_hidden_puzzle.clvm', 'singleton_top_layer.clvm', etc.
breaking In version 0.20.x, the puzzle module structure was reorganized. Imports from 'chia.puzzles' directly may break. Use full submodule paths like 'chia.puzzles.p2_delegated_puzzle_or_hidden_puzzle'.
fix Update imports to use the new nested module layout. For example, change 'from chia.puzzles import p2_delegated' to 'from chia.puzzles.p2_delegated_puzzle_or_hidden_puzzle import ...'.
gotcha The 'load_clvm' function caches compiled puzzles. If you modify a .clvm file at runtime, the cached version is used; restart the interpreter to see changes.
fix Clear the cache by calling 'load_clvm.cache_clear()' (Python 3.8+) or reload the module.
deprecated Some legacy puzzle names (e.g., 'p2_delegated_puzzle') are deprecated in favor of 'p2_delegated_puzzle_or_hidden_puzzle'. The old names may be removed in a future release.
fix Use the full name 'p2_delegated_puzzle_or_hidden_puzzle' for new code.

Loads a CLVM puzzle from the bundled .clvm files and prints it.

from chia.puzzles.load_clvm import load_clvm
from chia.types.blockchain_format.program import Program

# Load a standard puzzle
puzzle = load_clvm('p2_delegated_puzzle_or_hidden_puzzle.clvm')
print(puzzle)

# Optionally export to hex
print(bytes(puzzle).hex())