Recover the CLVM puzzle and solution of a spent Chia coin

A coin record contains a puzzle hash, while debugging a spend needs the revealed puzzle and the solution supplied to it. The full node can return both for an actual spend.

Request the spend height

Set COIN_ID to the 32-byte coin name in hex and SPENT_HEIGHT to the confirmed spend height. A coin's creation height can differ substantially from this value. Use those two identifiers together.

args=$(jq -cn --arg id "$COIN_ID" --argjson h "$SPENT_HEIGHT" '{coin_id:$id,height:$h}')
chia rpc full_node get_puzzle_and_solution "$args"

Verify what was executed

Compare the tree hash of the revealed CLVM puzzle with the puzzle hash on the original coin. Decode the solution against that puzzle and inspect the resulting conditions with a compatible evaluator. A puzzle hash alone cannot reconstruct arbitrary unspent puzzle code, and local evaluation still needs consensus context for height and announcements.

docs.chia.net get_puzzle_and_solution