Expand description
§Puzzles
Chia coins have a puzzle, which controls how it can be spent.
The solution is used as the arguments to the puzzle, and the
output is a list of [Conditions].
A puzzle consists of multiple layers composed together.
§Layers
A Layer is a subset of the logic that makes up a smart coin in Chia.
They are also referred to as “inner puzzles”, and the solution can be broken
up into “inner solutions” as well.
Generally, you can parse and construct the individual layers separately.
This allows them to be composed together freely. However, there are sometimes
additional restraints which limit the ways they can be mixed. For example,
the CatLayer cannot have another CatLayer as its inner puzzle, due to the
way it’s written. This would create an error when validating the announcements.
§P2 Puzzles
A p2 puzzle (meaning “pay to”) controls the ownership of the coin.
The simplest example of this is p2_conditions.clsp, which requires a signature
from a single public key and outputs a list of conditions from the solution.
The “standard transaction” (which is p2_delegated_puzzle_or_hidden_puzzle.clsp)
is a kind of p2 puzzle that adds additional flexibility. Specifically, support
for an inner puzzle, and usage of a delegated puzzle instead of directly conditions.
Generally, the p2 puzzle is the base layer in a coin’s puzzle, and everything else builds on top of it to restrict the way it can be spent or attach state.
§Primitives
A [Primitive] uses one or more Layer to parse info from a parent’s coin spend.
Generally, Layer has the ability to parse and construct individual puzzles and solutions,
and the composed [Primitive] struct can parse all of the information required to spend a coin.
The [Primitive] should also provide a way to spend the coin, and other utilities necessary.
Structs§
- The CAT
Layerenforces restrictions on the supply of a token. Specifically, unless the TAIL program is run, the supply cannot change. - Everything that is required to spend a
DataStorecoin. - The Delegation
Layeris used to enable DataLayer delegation capabilities For more information, see CHIP-0035. - The DID
Layerkeeps track of metadata and handles recovery capabilities. It’s typically an inner layer of theSingletonLayer. - An intermediate launcher is a coin that is created prior to the actual launcher coin. In this case, it automatically creates the launcher coin upon being spent.
- A singleton launcher is a coin that is spent within the same block to create a singleton. The first coin that is created is known as an “eve” singleton. The
Launchertype allows you to get the launcher id before committing to creating the singleton. - Everything that is required to spend an NFT coin.
- The NFT ownership
Layerkeeps track of the current DID that owns the NFT. It also contains a transfer layer, which is used to transfer ownership of the NFT. The inner puzzle layer is commonly used for determining ownership (in the key sense, not DID). - The NFT state
Layerkeeps track of the current metadata of the NFT and how to change it. It’s typically an inner layer of theSingletonLayer. - The Oracle
Layerenables anyone to spend a coin provided they pay an XCH fee to an address. It’s typically used withDelegationLayer. - The p2 delegated conditions
Layerallows a certain key to spend the coin. To do so, a list of additional conditions is signed and passed in the solution. Typically, theStandardLayeris used instead, since it adds more flexibility. - The p2 delegated singleton
Layerallows for requiring that a singleton be spent alongside this coin to authorize it, while also outputting conditions. - The p2 1 of n
Layerallows for picking from several delegated puzzles at runtime without revealing up front. - The p2 singleton
Layerallows for requiring that a singleton be spent alongside this coin to authorize it. - The royalty transfer
Layeris used to transfer NFTs with royalties. When an NFT is transferred, a percentage of the transfer amount is paid to an address. This address can for example be the creator, or a royalty split puzzle. - The settlement
Layeris used to spend coins that are part of an offer. - The singleton
Layerenforces uniqueness on a coin, which is identified by the launcher id. It contains an inner puzzle layer, which determines the actual behavior of the coin. Only one singleton can be created when the coin is spent, preserving the lineage of the asset. - The standard
Layeris used for most coins on the Chia blockchain. It allows a single key to spend the coin by providing a delegated puzzle (for example to outputConditions). - The Writer
Layerremoves an authorized puzzle’s ability to change the list of authorized puzzles. It’s typically used withDelegationLayer.
Enums§
Constants§
Traits§
- An individual layer in a puzzle’s hierarchy.
Functions§
Type Aliases§
- This is the actual puzzle name for the
StandardLayer.