Coin Set Intro
In any given blockchain, one of the most fundamental questions is, "How do we keep track of the state of the whole system?" Bitcoin uses the Unspent Transaction Output (UTXO) model. Ethereum, along with many other blockchains, use the account model. Chia uses the coin set model, which is similar to UTXO.
The differences between the above models will be covered in the Coin Set vs UTXO page and the Coin Set vs Account page. For now, we'll start with a brief explanation of the coin set model.
The mantra everything is a coin will go a long way in helping you to understand the coin set model. There are no accounts. There are only coins.
Coins may only be spent once and anyone can attempt to spend them. However coins are locked with specific rules. They are written in Chialisp, a Turing-complete language with no side effects, allowing for complex functionality, including composability and interoperability between coins.
The majority of Chia's coins have one simple rule – "Anyone with the right private key can spend me."
Key Features
- As stated above, Chia's blockchain only understands coins. There are no accounts at the blockchain level.
- Technically the coins do not have owners. Anyone can attempt to spend any coin. Most coins are secured such that only someone who possesses a certain public/private key pair may spend them. This person is the coin's de facto "owner."
- The coin set is the total set of all coins on Chia's blockchain.
- The minimum value of a coin is 0 mojos. The theoretical maximum value of a coin is around 18 million XCH (2^64-1 mojos). Each coin can be of any value within this range.
- Note 1: One use case for a zero-mojo coin is to convey information. For example, upon being spent, a zero-mojo coin could make an announcement for a singleton to recreate itself
- Note 2: Singletons must have an odd-numbered value, so their minimum value is 1 mojo (1 trillionth of an XCH)
- The first block of Chia's blockchain introduced four coins to the coin set, with a total value of 21 million XCH. This is the pre-farm, controlled by Chia Network Inc.
- Each additional block introduces a reward of two coins to the coin set (see the Block Rewards page for more info). For the first three years of Chia's blockchain, the targeted daily average to be introduced is 9216 XCH. This amount will be cut in half in 2024, 2027, 2030, and 2033, after which the targeted daily average will always be 576 XCH. While the exact amount introduced on any given day will vary slightly, one can predict the total amount of XCH in the coin set at any given time, with a high degree of accuracy.
- Each coin can only be spent once. Thus, a coin has only two states: unspent and spent. (Technically, there is a third state: not created. This happens when there is a re-org and the creation transaction gets reverted. Re-orgs in Chia are rare, though possible.)
- A coin's value cannot be destroyed. Instead, when a coin is spent, its value is released. One or more new coins will be created in the same block, the total value of which will equal the value of the spent coin.
- The coins themselves are highly programmable, so a wide variety of behavior is possible when a coin is spent.
Blockchain
The Chia blockchain, as explained in the consensus section, is a linked list of blocks, agreed upon by nodes. Nodes also maintain a table of coins. At a low level, a coin in Chia is a record of ownership of a certain amount of XCH, which can be unlocked by providing the correct puzzle and a valid solution.
These 3 properties make up each coin, and when hashed together form its id:
- Parent Coin Id
- Puzzle Hash (hash of the program)
- Amount (in mojos)
The ID of a coin is computed by hashing together its three fields, where amount is encoded in CLVM format:
(sha256 parent_coin_id puzzle_hash amount)