<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Fizpawiz on Medium]]></title>
        <description><![CDATA[Stories by Fizpawiz on Medium]]></description>
        <link>https://medium.com/@fizpawiz?source=rss-db39811b347e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*J-aMW1hsXev_cfaI</url>
            <title>Stories by Fizpawiz on Medium</title>
            <link>https://medium.com/@fizpawiz?source=rss-db39811b347e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 05:26:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@fizpawiz/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Singleton Fast Forward]]></title>
            <link>https://medium.com/@fizpawiz/singleton-fast-forward-71a8f1ef37ba?source=rss-db39811b347e------2</link>
            <guid isPermaLink="false">https://medium.com/p/71a8f1ef37ba</guid>
            <category><![CDATA[chia-blockchain]]></category>
            <dc:creator><![CDATA[Fizpawiz]]></dc:creator>
            <pubDate>Wed, 05 Mar 2025 23:48:43 GMT</pubDate>
            <atom:updated>2025-03-05T23:48:43.758Z</atom:updated>
            <content:encoded><![CDATA[<p>First, I no longer work for Chia. I left to go create a startup based on Chia. More on that later… :-) Nothing in this article is reviewed or endorsed by Chia. Assume there are errors.</p><p>Grant asked me write a little explainer on Singleton Fast Forward. Sounded like a fun way to procrastinate all the other things I’m supposed to be doing, so here’s my take.</p><p>Singleton Fast Forward was introduced in Chia 2.2.1 in February 2024, originally to support DataLayer-based on-chain oracles:<br><a href="https://www.chia.net/2024/02/28/version-2-2-1-release/">https://www.chia.net/2024/02/28/version-2-2-1-release/</a><br>Using DataLayer for on-chain oracles will be incredibly powerful, once the community starts building them.</p><p>When we think of blockchain oracles, we generally think of price oracles, which can be used to signal the broader market price for an asset on chain, where that information would not otherwise be available. DataLayer could not support highly-volatile data like asset prices, because DataLayer requires an on-chain spend to update.</p><p>There are lots of use cases for more static oracles. Consider a DataLayer-based oracle that contains a rarity score for all of the NFTs in a collection. With such an oracle and some offer-file magic, a buyer could create an offer to buy any NFT in a particular collection below a certain rarity score. For example, a buyer could create an offer to buy any ChiaPhunk with rarity below 5000 according to a specified oracle for 0.5 XCH. To take the other side of the offer, the seller would have to include an announcement from that oracle that the NFT they were selling was actually a ChiaPhunk and had a rarity below 5000.</p><p>Michael Taylor and Yakuhito have done amazing work on DataLayer and have really made on-chain oracles possible since Singleton Fast Forward came out. I know those two are well-respected in the community, but I still think they don’t get enough credit. Send them XCH :-)</p><p>The challenge with oracles is the case where lots of people want to use the oracle at the same time. Imagine two completed offers that use the same oracle land in the same block. Both will be attempting to spend the same oracle coin, and so ordinarily one of them would fail.</p><p>Singleton Fast Forward solves this. One important observation is that using the oracle to make an announcement does not change the oracle. In technical terms, the puzzle hash of the singleton is the same before and after the announcement spend. In fact, most spends of oracle coins will be announcements, so the puzzle hash won’t change across many spends of the oracle singleton.</p><p>With Singleton Fast Forward, when a spend bundle containing a singleton hits the mempool and the specified singleton coin has already been spent, then the mempool will find the current unspent coin for that singleton. If the unspent coin has the same puzzle hash as the coin specified in the spend bundle, then the spend bundle will “fast forward” to the unspent coin, enabling that spend bundle to succeed. Fast forward even works when there are multiple spends of the singleton in the block: in that case all but one of the spends will be ephemeral.</p><p>An interesting side note is that this is the only case where the mempool or the node actually knows anything about any specific puzzle. Normally the node just runs whatever puzzle and solution are given for each coin. Singleton Fast Forward inspects the puzzle to detect that a particular coin spend is a singleton to determine whether that coin spend is eligible for fast forward. (Technically, there are a bunch of other criteria for Fast Forward eligibility, such as not using AGG_SIG_ME, but that&#39;s beyond the scope of this article.)</p><p>Singleton Fast Forward is also critically important for Vaults, but those were created after I left Chia, so I’ll have to let someone else speak to them.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=71a8f1ef37ba" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Decentralized Names on the Chia Public Blockchain]]></title>
            <link>https://medium.com/@fizpawiz/decentralized-names-on-the-chia-public-blockchain-823adb6cc2af?source=rss-db39811b347e------2</link>
            <guid isPermaLink="false">https://medium.com/p/823adb6cc2af</guid>
            <category><![CDATA[chia-blockchain]]></category>
            <dc:creator><![CDATA[Fizpawiz]]></dc:creator>
            <pubDate>Fri, 25 Aug 2023 05:42:38 GMT</pubDate>
            <atom:updated>2023-08-27T03:14:00.078Z</atom:updated>
            <content:encoded><![CDATA[<p>First, although I work for <a href="https://chia.net/">Chia Network Inc</a>, the ideas and opinions presented on this Medium account are entirely mine and do not necessarily reflect those of my employer.</p><p>In this article, I will present a proposal for associating human-readable names with singletons on chain in a fully-decentralized way. I am no longer a developer, and cannot efficiently implement these ideas myself. Still, I understand the Chia technology well, and I hope that this article provides a starting point for someone to implement a fair, efficient and completely decentralized name registry.</p><p>So first off, what is the goal? What would such a registry accomplish?</p><ul><li>Anyone should be able to register a name for something they own</li><li>No one should be able to register a name for something they don’t own</li><li>No individual or group should be able to prevent someone from registering a name, nor forcibly take a name that has already been registered</li><li>There must be some cost to registering a name</li><li>No single individual or closed group should profit</li><li>It should not be possible to identify the name being registered before the registration is successfully completed</li><li>The registry should not depend on ongoing maintenance or support from any particular individual or group</li><li>There should be some incentive to release a name when it is no longer needed</li><li>There must be a way to transfer a name</li><li>There must be an efficient way to read the current state of the name registry, and to detect changes</li><li>There must be an efficient way to prove ownership of a name, both on chain and off chain</li><li>Ideally, there should be a way to nest name registries to create namespaces</li><li>Ideally, there should be a way to create permissioned namespaces</li><li>Ideally, there should be a way to support a fully decentralized TailDatabase</li></ul><p>With these goals in mind, what would a solution look like? First, it will need to be a fully on-chain, permissionless protocol because any centralized solution would give the service provider the ability to choose which requests to honor, and thus be subject to censorship. Second, there will need to be open-source tools available to interact with that protocol so that wallets can integrate the necessary functionality.</p><p>Here is the user experience I hope to achieve:</p><ul><li>A user decides to create a name for a singleton. For example to associate a name with an application stored in a DataLayer table (a “chapp”). Or to associate the name with a DID, such as for a NFT creator.</li><li>The user writes the request to add the name to the blockchain in a way that includes the hash of the name, a deposit in XCH that will be held to secure the name and a tip in XCH for whomever records the name. To create the name, they will need to demonstrate ownership of the singleton that will be named.</li><li>At some point thereafter, someone will see that there are several outstanding requests, and will use the on-chain requests to update an on-chain registry, and will accept the offered tips for doing so.</li><li>Once registered, the requestor reveals the name registered</li><li>Wallets will be able to detect the update to the registry singleton, look at how the registry was updated, and apply the same updates to their internal copy of the registry.</li><li>Later, when the user decides they’re done with the name, they’ll write another request to the chain to delete the name and recover the deposit. They will again provide proof of owning the singleton. They will again include a tip, and at some point soon after, someone will execute the request and accept the tip.</li></ul><p>I really think it can be that simple for the users.</p><h3>Overview of Proposed Implementation:</h3><p>Everything is easier to understand with a diagram. Hopefully that even applies to text-heavy diagrams like these:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/661/1*2ArWufmrUj5VC6L9hmfbXQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/491/1*PQejqBIG11cCqWlXijo8aA.png" /></figure><p>What follows in the technical description section is a more detailed discussion of how I envision all of the above to work.</p><p>After that, we get into a few more interesting topics, such as:</p><ul><li>Namespaces, such as “fizpawiz.chia”</li><li>Permissioned namespaces, where a namespace administrator can assogn names</li><li>And finally, an approach to a fully-decentralized TailDatabase(!!!)</li></ul><p>At the end of this article, I also listed some open questions, most with proposed solutions, but I’d like to get feedback on them.</p><h3>Technical Description:</h3><p>What follows is (I hope!) a clear description of the proposed protocol that can be reviewed to understand exactly how it would work. Hopefully, readers will be able to assess the feasibility and security of the proposed solution, and if it looks good, use it as a template for implementation. Clearly describing code in English is challenging to say the least, and I’m sure I’ve made some minor errors, but I think the basic technique is sound.</p><p>The technical description does get a little detailed. If you don’t have time now to grok your way through the details, please do skip down to some of the later sections about how to read and use the name registry, how to create nested namespaces, and how to apply the same general approach to Tail Database.</p><p>To start, I think it is useful to be very clear about the terminology I’m using:</p><ul><li>Deposit amount: amount currently required to reserve a name. Matches the 1/8th coin amount currently being rewarded for finding blocks (which declines at halvings)</li><li>Tip amount: amount paid to whomever actually constructs the spend to update the name table.</li><li>Name: a name, which must be an atom and may need other restrictions (see “Open Questions” below).</li><li>Target singleton: the singleton to be referred to with a name. Note these do not need to be DIDs but can be any singleton: DataLayer, NFT, etc.</li><li>Launcher id: every singleton is identified by the id of the coin used to create the first generation of the singleton. The launcher id never changes through the generations of the singleton.</li><li>Name record: name hash, target singleton launcher id, deposit amount</li><li>Name table: table of name records</li><li>Name table merkle root: when the name table is represented as a merkle tree, this is the root of that tree that is stored on chain</li><li>Action: Either “insert”, “delete” or “rotate”</li><li>Request coin: a coin created by the actor submitting a request for an action that includes the name hash, the action to be performed and tip amount, among other things.</li><li>Transfer sibling: when two request coins are submitted to effect a transfer, one to delete the name and the other to insert it again with a different singleton launcher id, then each request coin considers the other its transfer sibling.</li><li>Deposit refund receive address: the address to which the deposit refund should be sent when deleting a name.</li><li>Ephemeral coin: in this context, this is an ephemeral coin that requires an announcement from the target singleton to spend and which is the only way to create a valid request coin.</li><li>Action record: The action record will include the name record, the action to perform, the transfer sibling coin id and the hash of the remaining parameters curried in to the request coin. If “insert”, then also includes the table records for the prior and subsequent records, sorted by name hash, along with the merkle paths for each. If “delete”, then also includes the merkle path for the table record to be deleted. If “rotate”, then includes the table records and merkle paths for two sequential records, where the lengths of the paths differ by at least two.</li><li>Name registry singleton: the singleton hosting the name table</li><li>Executor: the actor that actually constructs and submits the spend of the name singleton to update the name table. Can be anyone.</li><li>Executor receive address: the receive address of the executor to which tips are paid.</li></ul><p><strong>Coins:</strong></p><ul><li><strong>Ephemeral coin</strong>. Making a request for an update to a name registry involves two coins: an ephemeral coin and a request coin. The ephemeral coin has a fixed puzzle, with the name singleton launcher id curried in, which makes it easily found on chain. When spending the ephemeral coin, the solution requires the target singleton launcher id, target singleton mod parameters, the requested name hash, action (only “insert”, “delete” or “rotate”), transfer sibling, deposit refund receive address, tip amount, current block height and its own coin id. If “insert”, the deposit amount will be confirmed to be correct for the given block height, and assert_height_absolute will be used to confirm the given block height is not in the future. It will create a condition to assert a puzzle announcement from the target singleton of the ephemeral coin’s coin id, name singleton launcher id, the requested name hash, the action, the transfer sibling, deposit refund receive address and the tip amount. This ensures the requestor owns the target singleton and that the request parameters were not changed by a malicious farmer. It will create a request coin as the only child. The coin amounts for both the ephemeral coin and the request coin must be the sum of the deposit amount (if “insert” action) and the tip amount. The ephemeral coin will emit an assert_ephemeral condition to ensure it always has a child when recorded on chain.</li><li><strong>Request coin</strong>. The request coin will have the name singleton launcher id, target singleton launcher id, requested name hash, action, transfer sibling, deposit refund receive address, tip amount, current block height and grandparent coin id curried in. It will have two spend modes: abort and execute.<br><em>Abort mode</em>: When the requestor chooses to abort, the request coin will and the target singleton mod parameters in the solution. It will assert a puzzle announcement of this coin’s id and “abort” from the singleton with the curried launcher id and creates a child coin with the deposit and tip amount as a “pay to singleton” coin that the singleton can claim.<br><em>Execute mode</em>: When the executor spends the request coin to execute the request, the coin will accept the name table merkle root in the solution. It will emit a condition asserting that its parent coin had the ephemeral coin puzzle, and that its own amount is the sum of the given tip amount and current deposit amount. It will assert a puzzle announcement from the name singleton of this coin’s coin id. It will create a puzzle announcement with the message “exec”. If the transfer sibling is not nil, the request coin will assert a concurrent spend of that coin id. If the action is “delete”, then a child coin will be created in the amount of the deposit to be refunded, assigned to the given deposit refund receive address. No child coin is created if the action is “insert”.</li><li><strong>Name singleton</strong>. Each name registry is a singleton, and has a curried root hash for the name table, the standard transaction mod hash, and the request coin mod hash. On every spend, it accepts the executor public key, total tip amount and the list of action records in the solution. A minimum of 10 action records is required to spend the coin, and all action records must be sorted by name hash and action, and must be unique. It will emit an agg_sig_me of the entire solution using the given public key. The value of the coin is the total deposit amount for all included records. The value of each generation of the singleton is updated based on the deposit amounts in the actions processed. The total tip amount will be output as a coin to the executor receive address, calculated using the given public key and standard transaction mod hash. <br><em>For each “insert” record</em>: The puzzle will confirm that the given prior and subsequent name hashes sort before and after the given name hash and do not match the given name hash. It will confirm the hashes of the prior and subsequent name records match the start of the corresponding merkle paths, and confirm that the prior and subsequent merkle paths both correctly reach the current merkle root. It will identify the lowest common node in the merkle paths, and insert a node as appropriate and then recalculate the merkle root. It will create a puzzle announcement of the request coin’s coinid. It will assert a puzzle announcement from the request coin of the message “exec”.<br><em>For each “delete” record</em>: The puzzle will confirm that the merkle path given exists in the merkle tree and that the record to delete does not have a zero deposit amount. It will promote the peer to delete the node and recalculate the merkle root. It will emit a create_coin to p2_singleton for the deposit amount so that the owner of that singleton can receive the returned deposit. Finally, it will create a puzzle announcement of the request coin’s coin id and assert a puzzle announcement from the request coin of the message “exec”.<br><em>For each “rotate” record: </em>The puzzle will confirm that the given name records match the leaves in the associated merkle paths. It will also confirm the merkle paths are correct and that the merkle roots match the current merkle root. It will find the lowest common node in the two paths — that will be the pivot node. It will confirm that the first leaf is the rightmost child of the left branch of the pivot node and that the second leaf is the leftmost child of the right branch of the pivot node. It will also confirm that the merkle path lengths differ by at least two. It will determine whether to do a left or right rotation based on which path is longer and then calculate the new merkle root from the appropriate child of the pivot node.</li><li><em>Name reveal spend mode</em>: Once a name hash has been inserted into the name registry, a name reveal spend will allow the owner to announce the name associated with the name hash. The solution requires the name record, the merkle path to the root, and the name. First, the name will be verified to be valid, for example that it includes only valid characters. Next, the puzzle will verify that the given name matches the name hash in the name record. Next, it will verify the hash of the name record matches the starting hash in the merkle path. Next it will verify the merkle hash is valid. Finally, it will verify the end of the merkle path matches the curried root. If all of these checks are successful, then the spend will complete successfully with no output conditions. Note the upcoming singleton spend aggregation feature of the Chia blockchain will prevent this from becoming a DOS vector on the name registry singleton.</li><li><em>Proof of name alternate spend mode</em>: To support proving that a name is associated with a particular singleton on chain, another alternate spend mode should allow anyone to spend the name singleton with a solution that includes a name record and the current merkle path of that name record. The coin will verify the name record hashes to the starting value in the merkle path, that the merkle path is valid, and that the merkle path ends in the current root. If so, it will create a puzzle announcement of the name and the associated singleton launcher id. Note the upcoming singleton spend aggregation feature of the Chia blockchain will prevent this from becoming a DOS vector on the name registry singleton.</li><li><em>Nested namespace alternate spend mode</em>: To support cascading name registries, the name singleton should have an alternate spend mode that accepts in the solution the ephemeral coin’s coin id, name singleton launcher id, the requested name hash, the transfer sibling, deposit refund receive address and the tip amount (but not action) and emits the necessary puzzle announcement to facilitate creating a request coin to add the current name registry as a named singleton in another registry. To avoid DOS attacks, this spend mode should assert_concurrent_spend of the ephemeral coin. Note there should be no way to create the necessary announcement to request removing the singleton from the parent name registry.</li></ul><p><strong>Deployment</strong></p><p>To deploy a name registry, construct a starting merkle tree with two nodes that are the minimum and maximum possible name values, nil target singleton launcher ids and zero deposits. Launch the name singleton with this merkle root.</p><p>To deploy a nested namespace, first deploy the nested namespace as a normal namespace, and then use the alternate spend mode to create the appropriate request coin to add it to the higher-level namespace.</p><p><strong>Updating the Name Singleton</strong></p><p>Anyone can be an executor and make an update to the names singleton. They will earn the tips from the requested actions for their efforts. They will need to pay the blockchain fee to get the update included on the chain from the tips earned.</p><p>The executor will monitor the chain for request coins by puzzle hash. When there are at least 10 outstanding requests, they can create a spend of the names singleton. Requiring a minimum number of requests and requiring they be unique will deter those that would otherwise attempt to spend the name singleton for every action request.</p><p>The spend bundle will include all of the associated request coins. These coins do not create output coins but spending them releases their value. That value can then be captured by the name singleton for deposits on insert, or paid to the executor as a part of the tip.</p><p>When constructing the merkle paths in the action records, remember that each action updates the merkle root, so the merkle paths in each subsequent action should be constructed from the root output by the prior action.</p><p>Executors are expected to include appropriate rotations in every update to keep the tree as nearly balanced as possible. Hopefully, by including that behavior in the open-source executor driver, most executors will contribute to maintaining the tree in a balanced state.</p><p><strong>Reading the Name Singleton</strong></p><p><strong>By wallets, offchain</strong>: The current set of name records can be read by reading the solutions provided to each generation of the singleton. Anyone with access to a full node can “follow” the singleton to get this sequence of solutions.</p><p><strong>On chain</strong>: The second alternate spend mode of the name registry singleton allows it to create announcements of valid names and their associated singleton launcher ids. It is straightforward to imagine a “pay to name” puzzle that would have a name registry launcher id and name hash curried in, (along with several necessary mod hashes). To spend a “pay to name” coin, a solution would need to be provided with the current name registry root hash and a singleton launcher id. The coin would only successfully spend if it could assert an announcement from the name registry singleton that the name was associated with the given singleton launcher id. If so, it would emit a create_coin with a “pay to singleton” puzzle that could only be spent by an announcement from that named singleton. This would only really be useful in cases where names were expected to be transferred.</p><p><strong>Concise Name Proofs</strong></p><p>If all you want to do is confirm that a given name is currently valid and references a specific target singleton launcher id, the prover can provide the name record and the current merkle path for that name. The verifier can check that merkle path starts with the hash of the given name record and then confirm the terminal hash in the path matches the current root hash on chain.</p><p>The prover can also provide the current name singleton parent coin id and amount and so deliver a concise name proof. The verifier can easily calculate the coin id for the name singleton from the given proof and easily ask any full node if that coin exists and is unspent to verify the proof.</p><p>A useful service would be one that provides an up-to-date table of all of these concise name proofs for every name in the table. That way, anyone that knows the current on-chain root hash can use the table to quickly check any name.</p><p>The table above can be audited for completeness by overlaying all of the provided merkle paths and confirming there are no gaps, thus preventing censorship by omission.</p><p>Another useful service would be a name lookup service that you query with the name and it provides the above proof.</p><h3>Cascading Names / Namespaces:</h3><p><strong>Namespaces</strong>. Since the name singleton associates names with other singletons, we can easily construct namespaces. For example, the top level name registry singleton can have a named singleton “chia”. The singleton associated with the name “chia” can also be a name registry singleton. In that lower-level name registry, I can have the name “fizpawiz”. In that way, I can use the name “fizpawiz.chia” as a way to indicate a singleton that represents “fizpawiz” and is a part of “chia”.</p><p><strong>Namespaces based on intent</strong>. Some namespaces may be used to describe the intent of the referenced singleton. For example, the top-level name “did” might indicate that all of the entries in the next lower-level name registry are all DIDs. Same with “.dl” for DataLayer tables, “.nft” for NFTs, etc. Similarly, top-level names can be more semantic than descriptive. So “.site” might be an html-based site stored in a DataLayer table. Also, “.chapp” might be an app similarly stored in a DataLayer table. Or “.python” might be a python library made available through DataLayer.</p><p><strong><em>Can you imagine</em></strong><em> opening a browser and typing “chia://cadt.chapp” and going directly to a version of the Climate Action Data Trust hosted locally from source files confirmed to exactly match those provided by the CADT Council? Or reference “chia://leftpad.js:5” to exactly use the 5th generation of the “leftpad” library Datalayer singleton in the “js” namespace, which will always be available and immutable thanks to the blockchain and mirrors. Not that you’d want to, but you could even emulate the existing DNS name structure: “chia://www.chia.net” which would involve two namespaces, “net” and “chia”, with a DataLayer singleton at the “www” name.</em></p><p><strong>Concern: cyclical graph</strong>. A name singleton can be added a to itself with a name, which introduces a cycle that could cause some readers of the graph to enter infinite loops. Clients of the name registry will need to take care to avoid this situation.</p><p><strong>Concern: the “.” character</strong>. If a name is allowed to have the “.” character, then names can be ambiguous. “fizpawiz.chia” could be either one name, or a cascaded name. We will probably need to disallow “.” in names.</p><h3>Permissioned Name Registry</h3><p><strong>Organizational names</strong>. A version of the decentralized name registry could be created that is not decentralized and is instead owned by a particular entity in one way or another. These permissioned name registries would not need ephemeral or request coins, nor minimum numbers of action records nor deposits, nor name hashes and reveals. They would allow the owner of the top-level name to choose who receives names in the lower-level name registries. Thus, for example, “fizpawiz.chia” could only be assigned by the owner of the “chia” top level name. Users of this name would know that “fizpawiz” was a member of “chia”.</p><p><strong>The “@” character</strong>: The “@” character could be used when transitioning from a higher-level namespace to a lower-level, permissioned namespace. So you’d get “fizpawiz@chia”, where “chia” is a name in the top-level namespace and “fizpawiz” is in the permissioned namespace. This would also introduce the need to disallow “@” in names.</p><h3>TailDatabase:</h3><p>The above name registry mechanism doesn’t work for TailDatabase because the thing being named is not a singleton that can be spent by the owner to request the name.</p><p>A global TailDatabase in this model will require an update at mint, which can be detected by detecting the “eve” coin. There is no way to directly detect the “eve” coin. So, to detect a mint event, we will use a “pre-eve” ephemeral coin in the mint. The only child of this coin is the eve coin for the CAT. The TAIL hash and inner puzzle are also passed in so the pre-eve coin can confirm the child coin will be a CAT. Since the pre-eve coin is not a CAT, this is a mint event.</p><p>The pre-eve coin will also require a non-refundable “deposit”, calculated in the same way as the name deposit, to defend against maliciously polluting the CAT tail database. This can be accomplished by sending that amount to the brick address. I think this will require a larger amount than for names, such as the current amount of the 7/8ths coinbase reward.</p><p>The pre-eve coin will create a puzzle announcement of the TAIL being minted, along with the hash of a metadata record containing the CAT name, code, description, image NFT launcher id and tail reveal, as passed in via the solution. Be aware that a malicious farmer could alter the solution while the spend is in the mempool, so the driver code to mint the CAT with a tail database update should confirm that the correct metadata hash got recorded in the TailDatabase update after the transaction.</p><p>If the metadata hash was recorded correctly, the tail datatabase singleton will allow a metadata reveal spend, like the above name reveal spend, that allows the owner to announce the name, code, description, etc. The metadata reveal spend will also verify that the metadata is correct, e.g. that the name has only valid characters, that the code is appropriately short, that the NFT launcher id is 32 bytes, etc.</p><p>The actual tail database will function similar to the name registry described above, with the CAT pre-eve coin functioning as the request coin. The requirements for tips and a minimum number of updates per spend will not be necessary since the minter is the tail database updater.</p><p>Note that I do not propose any mechanism to ensure that the tails themselves are unique. As far as I can tell, that would require that a complete second merkle tree of tails would need to be maintained with every insert, and that feels like excessive overhead for little benefit.</p><p>To use this mechanism, we will need to create a new CAT minting tool that will update the taildatabase at mint time.</p><p>We will need to “seed” the tail database singleton root hash with the current contents of the existing TailDatabase.</p><p>A tail lookup service as described for names would be a valuable service. Also a reverse lookup to fetch all of the names recorded for a particular tail.</p><h3>Open Questions:</h3><ul><li>Should the name registry require names to consist of characters from a particular character set? If so, would that exclude certain populations?</li><li>I think we should disallow some characters, such as “.”, “@”, “:”, “/” and “!”. Likely some others also, like quotes and all kinds of braces. Maybe a name registry should only allow alphanumerics? How can we efficiently check for alphanumerics vs symbols on chain? Especially in expanded character sets to be more inclusive of global languages?</li><li>Case issues could be a problem. Many will expect “fizpawiz” and “Fizpawiz” to reference the same person. Is there a way to efficiently check that a name is all lowercase? Or upper, doesn’t matter. We just need to make sure we don’t have a name accidentally or maliciously created that differs only in case from another name. A concern on this: if I recall correctly, the romanizations of some languages that natively use non-Latin alphabets treat the upper-case and lower-case letters as representing different characters in the native language. Thus, ignoring case strangely limits the ability to correctly express names in those romanizations. I don’t know how to solve for that.</li><li>Should the name registry attempt to prevent the same target singleton from appearing with multiple names? I don’t think so. I don’t think the problem is worth the solution, as it would require a second merkle tree to assure uniqueness of target singleton launcher id.</li><li>I don’t think there is any way to prevent typo squatting. It gets worse the larger the allowed character set. This is a real concern, but allowing anyone to censor name registrations is a slippery slope. I would like to propose, as a potential solution, that any user interface that displays a name prefix it with a <a href="https://www.blockchaincommons.com/specifications/Lifehash-info/">LifeHash</a> of the singleton launcher id.</li><li>For the same reason, I don’t think there is any way to police offensive names. Preventing censorship includes putting up with things you don’t like.</li><li>I don’t think there is any way to prevent name squatting. Once someone owns the name (e.g. “Microsoft”, owned by some dude not affiliated with Microsoft) there is no way to take it away from them. That’s good. And its going to be very upsetting occasionally.</li><li>Should there be an expiration mechanism? Offhand, I would say no, because we don’t want to take things away from people without notice, and we don’t have a way to notify them. A watchtower could help, but that provides an attack vector where a watchtower operator could maliciously omit notices to hijack a name. But not expiring names leaves the top-level namespace open to getting polluted with a lot of long-forgotten names that can never be recovered. Which may not be bad, actually.<br><em>Thought</em>: What if we create the top-level namespace to have very high deposit requirements, and immediately introduce a set of lower-level namespaces (e.g. “did”, “chapp”, “site”, “nft”, etc) that have lower deposit requirements to encourage people to use those namespaces instead of the top-level namespace?</li><li>There is an attack where a malicious farmer could steal the tip amount from the executor. I don’t know a way around it, but it will only happen when a malicious farmer actually farms the block with the name singleton update. Maybe it is a non-issue: the tips are not likely to ever be very high, so there is very little incentive for such malware to become prevalent.</li><li>Last open question: should this have been a CHIP?</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=823adb6cc2af" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Primer on Chia DataLayer]]></title>
            <link>https://medium.com/@fizpawiz/a-primer-on-chia-datalayer-e4a4796c390e?source=rss-db39811b347e------2</link>
            <guid isPermaLink="false">https://medium.com/p/e4a4796c390e</guid>
            <category><![CDATA[chia]]></category>
            <category><![CDATA[datalayer]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Fizpawiz]]></dc:creator>
            <pubDate>Wed, 15 Mar 2023 02:11:41 GMT</pubDate>
            <atom:updated>2023-03-15T12:20:43.920Z</atom:updated>
            <content:encoded><![CDATA[<p>First, although I work for <a href="https://chia.net/">Chia Network Inc</a>, the ideas and opinions presented on this Medium account are entirely mine and do not necessarily reflect those of my employer.</p><p>The below is my personal description of Chia DataLayer and is not to be considered official documentation. It has not been reviewed by the Chia documentation team nor the engineering team and will not be maintained. Any errors or inaccuracies are entirely my fault. If it is confusing or unclear, that is also my fault. There is nothing here that is not public information available elsewhere, only my best effort to make it easier to understand.</p><p>I’m writing this because <strong>I strongly believe this will become a foundational protocol for working with data that will change how we think about data ownership, durability and authenticity</strong>. I’d like to help get the ball rolling with Chia DataLayer by helping more people to understand what it is, how it works, and some initial thoughts on what you might do with it.</p><h4>Introduction</h4><p>The world has many ways of dealing with data. What makes Chia DataLayer different?</p><ul><li><strong>You Own Your Data</strong>. You have to use your cryptographic key to change your data, and without that key, no one can change your data.</li><li><strong>Censorship Resistance</strong>. You can use nearly any channel to make your data available to others and still ensure they data they receive is intact. Censorship in one channel or one jurisdiction does not affect your ability to be heard.</li><li><strong>Peer-to-peer</strong>. There is no central server in Chia DataLayer, and everyone is free to use it how they wish.</li><li><strong>Auditability</strong>. Every update you make to your data is recorded on the immutable Chia blockchain, at a specific block height. Data cannot be retroactively altered.</li><li><strong>Accountability</strong>. Anyone that has a copy of the data published to DataLayer can prove that the data is correct and will know the key used to record that data. The holder of that key can be held accountable for the data they publish.</li><li><strong>Durability</strong>. Anyone can participate in ensuring the durability of data stored on Chia DataLayer, regardless of the who published that data.</li><li><strong>Privacy</strong>. While the blockchain is used to prove that any particular copy of the data in Chia DataLayer is correct, the data is actually transferred between users entirely off-chain. You can decide whether to make your data publicly available, or to limit access, based on how you choose share the data files. You may not share the data at all, and simply use the blockchain to assure auditability.</li><li><strong>Smart Contracts</strong>. Data stored in Chia DataLayer is available for use in Chialisp smart coins. I believe this feature by itself will have a huge impact on how smart contracts are written, and will be a tremendous differentiator compared to other smart contract languages and platforms.</li></ul><h4>This article provides:</h4><ol><li>a completely non-technical mental model for how DataLayer works</li><li>a mapping of that mental model to the actual implementation on Chia</li><li>killer feature: proofs of inclusion</li><li>two party commits: proofs of inclusion in offer files</li><li>a tour of the RPCs available to actually use DataLayer</li></ol><p>Hopefully at the end of this you’ll have a solid, working foundation for building decentralized applications with Chia DataLayer.</p><h3>Mental Model in a Metaphor</h3><p>I think the most important thing is to offer a solid mental model for how DataLayer works. To that end, I would like to offer a simple abstract analogy that I hope will help to build an intuitive understanding of Chia DataLayer. Immediately after, I will re-do the scenario in a very concrete way, describing exactly how DataLayer works at each step. Feel free to skip this section if abstract analogy is not your thing. The subsequent section will still make sense without it.</p><p>In our scenario, Alice, Bob and Carol are sharing pictures of their pets in a group chat.</p><p>Alice writes:</p><pre>Alice (10:30pm): My picture will be called AlicePet<br>Alice (10:30pm): I will make AlicePet available at http://alice.com/<br>Alice (10:31pm): AlicePet version 1 is a picture of a cat</pre><p>Bob sees this and goes to http://alice.com/AlicePet_1.jpg to fetch the picture. When he gets it, he verifies it is indeed a picture of a cat, and so is confident he has the correct picture.</p><p>Now it is Bob’s turn to share:</p><pre>Bob (10:45pm): My picture will be called BobPet<br>Bob (10:46pm): I will make BobPet available at http://bob.com/<br>Bob (10:47pm): BobPet version 1 is a picture of a dog</pre><p>Alice sees what Bob has posted and goes to http://bob.com/BobPet_1.jpg to fetch the picture. When she gets it, she verifies that it is a picture of a dog, and so is confident she has the correct picture.</p><p>Alice thinks Bob’s picture is great and wants to help make it available to anyone that wants it. So she writes:</p><pre>Alice (11:00pm): I will make BobPet available at http://alice.com/</pre><p>Carol joins the group chat and sees all prior messages. She decides she wants to see Bob’s pet photo. She notices there are two locations available: http://alice.com and http://bob.com.</p><p>Carol picks one and goes to http://alice.com/BobPet_1.jpg. Alice must have made a mistake, because the picture she received was of a fish! Carol knows to discard the photo because Bob had said it would be a dog.</p><p>Carol then goes to http://bob.com/BobPet_1.jpg to fetch the picture. She confirms it is a dog and is satisfied she has the correct photo.</p><p>Bob now decides to update his pet photo.</p><pre>Bob (11:15pm): BobPet version 2 is a picture of a marmot.</pre><p>Alice fetches the photo from http://bob.com/BobPet_2.jpg and confirms the picture is of a marmot.</p><p>Carol has two choices of where to get the photo. She happens to select to get it from Alice again, who now already has the updated picture. Carol goes to http://alice.com/BobPet_2.jpg to fetch the photo and confirms it is a picture of a marmot, so she knows she has the correct photo.</p><p>Alice decides to stop sharing her pet photo:</p><pre>Alice (11:30pm): AlicePet is no longer available at http://alice.com</pre><p>Carol now decides she wants to see Alice’s photo, but there is nowhere for her to get it. Even though she is not able to get Alice’s photo, she still knows it should be of a cat, and that the cat photo was announced at 10:31pm.</p><p>Offline, Carol talks to Bob and he offers to provide her the photo. She opens the photo provided by Bob and confirms it is a cat, so Carol knows Bob has provided the photo that Alice had originally posted.</p><h3>Making the Metaphor Real</h3><p>So that was pretty silly, but hopefully it was illustrative of the protocols that DataLayer uses to communicate. Mapping the above to real Chia blockchain concepts:</p><ul><li>The “group chat” is the Chia blockchain. Everyone can observe it, and can contribute only new “messages” in the form of coin spends.</li><li>AlicePet and BobPet are DataLayer singleton coins. A singleton coin is a coin that has a long-lived identifier assigned by the blockchain called the <em>launcher id</em>. As a singleton, only one unspent coin with this launcher id can ever exist at any time. As a DataLayer singleton, it has additional functionality for maintaining the current hash of the table of data represented on chain by that singleton. If this paragraph doesn’t make sense, please see <a href="https://docs.chia.net/coin-set-intro/">Coin Set Intro</a> and <a href="https://chialisp.com/singletons">Singletons</a>.</li><li>The “pictures” are the actual tables of data. Each table can have any number of rows, and each row in the table consists of a key and a value where the key and the value can each be any blob of binary data. The only restriction is that there cannot be duplicate keys in the key-value store. The correct term for what I call a “table” is “data store”. You’ll see that name used in the documentation, but I have trouble getting used to that term.</li><li>The notion of “dog”, “cat”, “fish” and “marmot” in the story was the hash of the data in the data table. Specifically it is the hash of a Merkle tree version of the data, where each row is a leaf in the tree, but that is a detail for later.</li><li>The announcements of http URLs are done with announcement coins. These are simple XCH coins with a trivial wrapper puzzle that mostly just tags them as announcement coins as distinct from regular XCH. The coin hint is the launcher id of the DataLayer coin to which the announcement applies, and the memo is the URL, recorded in cleartext directly on the blockchain.</li></ul><p>Now we can rewrite the story using the correct Chia terms:</p><p>Alice creates her singleton using the DataLayer RPC create_data_store:</p><pre>Block 100: <br>    Spend XCH coin id: 0x123456 (value: 1 mojo)<br>    Create DL singleton coin (value: 1, launcher ID: 0x123456, hash: 0x0000)</pre><p>(For purposes of discussion, I’m using shortened placeholders for ids and hashes such as 0x123456 and 0x0000. In reality, these are really long values.)</p><p>Next Alice announces the URL where she will host the data using the add_mirror RPC:</p><pre>Block 101:<br>    Spend XCH coin id: 0xabcdef (value: 10 mojos)<br>    Create announcement coin (value: 10, hint: 0x123456, memo: &quot;http://alice.com&quot;)</pre><p>And Alice updates the data in her store with batch_update (update_data_store in CLI):</p><pre>Block 102:<br>    Spend DL singleton coin (launcher ID: 0x123456, hash: 0x0000)<br>    Create DL singleton coin (launcher ID: 0x123456, hash: 0x3845)</pre><p>For reference, <a href="https://docs.chia.net/datalayer-rpc">the DataLayer RPCs are documented here</a>.</p><p>Note that we can’t tell how many changes she made to the table in her update to the data just by looking at the blockchain. She could have added one row or 1000. All that is relevant on chain is that the hash of the data has changed.</p><p>Also note that the actual data is not stored on the blockchain, and does not get copied to all of the many validators globally. The data is transferred from user to user off-chain, and the blockchain is only used to validate that a particular copy of the data is correct.</p><p>Alice tells Bob her DataLayer singleton launcher ID is 0x123456, and he subscribes to it in his wallet with the subscribe RPC. On subscription, Chia DataLayer does several things: first, it looks up the singleton with that launcher ID and finds the current hash to be 0x3845. It then looks for any announcement coins with Alice’s DataLayer launcher ID as the hint, and finds one. It gets the URL http://alice.comfrom the announcement coin. Finally, it constructs a http request:</p><p>http://alice.com/123456-3845-full-1-v1.0.dat</p><p>This file is:</p><ul><li>Located at http://alice.com per the announcement coin</li><li>For the DataLayer singleton with launcher ID 123456 (“AlicePet”)</li><li>With the hash 3845 (“cat”)</li><li>Since Bob does not yet have any data for this singleton, we are requesting the full file, with all records, instead of the delta file with only the records changed since the last update.</li><li>This is update 1 of this DataLayer singleton</li><li>The file format version used in this file is v1.0</li></ul><p>Upon successfully receiving the file, and before making the data available to Bob, Chia will recalculate the hash of the data received and verify it matches the hash on chain. Assuming it matches, the data will be available to Bob using get_keys_values, get_keys or get_value.</p><p>It is worth stopping here for a moment to recognize what has happened. Alice published her own data signed with her own private key. That data is provably owned by Alice. And Bob can be absolutely sure that he has the exact data that Alice published and he knows exactly when she published it, despite receiving the data over an insecure channel (http) and receiving it an unknown amount of time after she published it. Alice and Bob did this entirely as peers, with no intermediary and no need for trust. That’s a big deal and the implications will be huge.</p><p>Bob does the same to publish his data using DataLayer:</p><pre>Block 110: <br>    Spent XCH coin: 0x745698 (value: 1 mojo)<br>    Create DL singleton coin (value: 1, launcher ID: 0x745698, hash: 0x0000)<br>    Spent XCH coin: 0xabcdef (value: 10 mojos)<br>    Create announcement coin (value: 10, hint: 0x745698, memo: &quot;http://bob.com&quot;)<br>Block 111:<br>    Spent DL singleton coin (launcher ID: 0x745698, hash: 0x0000)<br>    Create DL singleton coin (launcher ID: 0x745698, hash: 0xAB12)</pre><p>Notice in this case, the creation of the singleton and the announcement of the URL happen in the same block. That’s fine.</p><p>Bob now passes his DataLayer singleton launcher id (0x745698) to Alice. She uses subscribe to subscribe to Bob’s DataLayer singleton, and receives and validates Bob’s data in the same way. Upon success, the data is stored in a sqlite3 database in .chia/mainnet/data_layer/db/. All of the data for every DataLayer singleton that Alice publishes or subscribes to is stored in this database. Additionally, the files for Bob’s data are stored locally in .chia/mainnet/data_layer/db/server_files_location_mainnet/, along with the files for Alice’s data.</p><p>Next in our story, Alice decides to provide a <em>mirror</em> of Bob’s data. She has it, and she can be confident that it is correct. She uses add_mirror to make it available to others.</p><pre>Block 120: <br>    Spent XCH coin: 0x927403 (value: 10 mojos)<br>    Create announcement coin (value: 10, hint: 0x745698, memo: &quot;http://alice.com&quot;)</pre><p>There are lots of reasons to mirror data you don’t own, among them:</p><ul><li>To help ensure the data persists. If Bob’s machine gets wiped out, Everyone (including Bob) can still get the data from Alice and verify it is correct by checking the hash against the blockchain.</li><li>To help ensure the data is available. If Bob’s internet connection is flakey, or he doesn’t have the bandwidth to support the huge demand for his data, then having mirrors will ensure the data is available when others need it.</li><li>To make the data available at all. Bob may not be able to host inbound http requests. So he can just provide the files to Alice and let her host them. Anyone requesting the data can be confident that it is still Bob’s data, even though it is only available from Alice.</li><li>To hold Bob accountable for his data. Bob may want to pretend that data never existed, or to alter it and pretend the prior version never existed. By helping to make the verifiable data available Alice can ensure Bob can’t run from his data. Note that Bob doesn’t have to give Alice permission to host a mirror. It doesn’t matter how Alice receives the files, she can use them to host a mirror.</li></ul><p>Now Carol wants to see Bob’s data. Maybe Bob tells her his DataLayer singleton launcher id directly, or maybe Alice gives it to her. Or maybe she gets it through some website. Regardless of how she receives it, she calls subscribe on his singleton with ID0x745698.</p><p>As before, Chia DataLayer will look for announcement coins for that singleton, but now it will find two. If Carol directly calls get_mirrors, she will see both http://bob.com and http://alice.com. Initially, there is no basis to prefer one over the other, so it will simply pick one. Note that the announcement coin has a value (10 mojos in this example). Right now, that value is not used, but in the future it may be used to help clients select a mirror.</p><p>Carol happens to select Alice’s host to get the data. Nothing happens on chain when Carol subscribes. Bob has no way to even be aware that Carol has subscribed to and received the data. And Alice only knows that <em>someone</em> fetched Bob’s data from her, but cannot reliably know anything about who.</p><p>The data Carol receives is incorrect. This can happen for many reasons, from a simple file-management error on Alice’s part, or a data transmission error, or malicious intent from Alice or from a man-in-the-middle. Regardless, the data Carol receives does not hash to the same value that Bob recorded on chain, so Carol discards the data.</p><p>Carol then selects another mirror, this time <a href="http://bob.coma,/">http://bob.com,</a> and successfully receives the data. In future requests, Chia DataLayer will deprioritize mirrors that are unresponsive, don’t have the needed data, or return incorrect data.</p><p>Now Bob decides to update his data. He calls batch_update (update_keys_values) with a list of rows to insert and delete.</p><pre>Block 130:<br>    Spent DL singleton coin (launcher ID: 0x745698, hash: 0xAB12)<br>    Create DL singleton coin (launcher ID: 0x745698, hash: 0xF334)</pre><p>Chia takes the changes, applies them locally, calculates the new hash, and updates the singleton on chain with the new hash. It also creates the new files and stores them (by default) in a directory under the user’s .chia/mainnet/data_layer/db/server_files_location_mainnet/ folder. These files are for update 2 of the singleton, and so sit side-by-side with the files for update 1 without causing a filename collision, even if the hash ends up being the same (e.g., no net records inserted or deleted).</p><p>By default, Chia provides a little http server so that these files can be served directly from the machine with the wallet. This server is optional, and you can use DataLayer without it. You can start this server with chia start data_layer_http, or by flipping the relevant switch in the settings page in the GUI. However, this requires that you: a) have a static IP or a dynamic DNS name that can track your current IP and b) open the inbound port through whatever network infrastructure you have to that machine. I think this may be a significant hurdle for many users.</p><p>Alternatively, if you have a cloud hosting account somewhere, you can upload the file to your cloud account in a bucket that is accessible to the public. If your provider charges network data egress fees, you may want to put something like Cloudflare in front of it to prevent getting maliciously bombed with a huge egress bill. I personally host the DataLayer tables I publish and mirror on Google Cloud and use the Cloudflare free tier account to protect it. I wrote a little script to copy the files from my local machine to the cloud account. This is definitely not something most users would do.</p><p><strong>My open plea to the community:</strong> <em>I really hope to see DataLayer hosting services crop up, with a little uploader I can run locally that sends my DataLayer files to the hosting service and makes this whole part of the process easier. There is a good business model here too, as these providers can (and should) charge for their services and make a profit. Personally, I hope to see many such services hosted in different jurisdictions, and to have the ability to upload to multiple such services, to help with censorship resistance. If I could pay for that service with farmed XCH and upload the data through a VPN or Tor, I could ensure my anonymity as well. Maybe send me the bill in an offer notification with an NFT “receipt”? Ideally, I’d love to see a CHIP for the protocol for connecting to such services, so that the local uploader can be standardized.</em></p><p>Back to Bob and his update. As a part of subscribing to Bob’s DataLayer singleton, Alice and Carol’s Chia wallets are each now tracking Bob’s singleton. They will notice that it has been spent, and will read the new hash of the data from the blockchain. Alice and Carol don’t have to do anything to make this happen, the Chia wallet takes care of it.</p><p>Alice’s Chia wallet reacts first. There is only one mirror available that she does not own, http://bob.com, so it fetches the data from there. The download is successful, and the locally-calculated hash matches the hash on chain, so the data is accepted.</p><p>At this point, the updated data is now available through get_keys_values, get_keys, and get_value. Additionally, if she calls get_root_historyon Bob’s singleton, she’ll now see three hashes:</p><ul><li>0x0000 — the initial has before any data was added</li><li>0xAB12 — the hash of the first version of the data</li><li>0xF334 — the hash of the updated data</li></ul><p>(Here, “root” refers to the <em>root hash</em> of the Merkle-tree version of the data. It is a hash of all the data, but the data is hashed in a Merkle tree rather than all at once. This becomes much more relevant later.)</p><p>Alice can also see the history of the changes that Bob has made to his data using get_kv_diff. This RPC accepts any two root hashes in a given singleton’s history and returns the <em>net</em> rows inserted and deleted between those two root hashes. So Alice can distinguish between the changes Bob made in his first update and the subsequent changes made in the second update. The changes reported are net changes, so if a group of rows are both inserted and deleted in the updates between the two hashes provided to get_kv_diff, those rows will not show up in the diff output at all.</p><p>Now that Alice has the files for Bob’s update, she is able to mirror them. If she uses the default built-in http server, there is nothing she needs to do: the http server will serve those files the same as it had with the files for version 1. If she is hosting the files remotely, she will need some mechanism to send the files to the hosting location.</p><p>Next Carol’s wallet detects the update to Bob’s singleton. As before, it sees that there are two announced mirrors, selects one, downloads the files, successfully verifies the hash, and makes the data available to Carol.</p><p>What if Carol’s wallet had requested Bob’s data from Alice’s mirror before Alice had received it? That’s fine. Carol’s wallet will simply retry from another mirror and if none are available that have the data, simply wait in gradually increasing intervals before retrying again. In fact, each subscriber will wait a random (but small) amount of time after detecting an update on chain before attempting to fetch the data to give it a chance to propagate through the network without every subscriber requesting it simultaneously. Additionally, each subscriber will randomize the sequence of available mirrors from which it tries to download the data.</p><p>Finally, Alice decides to stop sharing her data, which Carol has not yet received. She calls delete_mirror and specifies exactly which mirror announcement coin to melt. The XCH in the announcement coin then gets returned to her normal XCH wallet.</p><pre>Block 140:<br>    Spend announcement coin (value: 10, hint: 0x123456, memo: &quot;http://alice.com&quot;)<br>    Create XCH coin (value 10 mojos, receive address specified by Alice)</pre><p>Now Carol decides she wants to subscribe to Alice’s DataLayer singleton. The Chia DataLayer wallet cannot locate an announcement coin that gives a URL to fetch the data, so no data can be downloaded. However, she can still use get_root_history to see all the hashes that had been recorded for Alice’s DataLayer singleton, and at what block height each had been recorded. She can also detect any new updates Alice may make. Alice can continue to update her DataLayer table with more data, and so long as she doesn’t publish the files anywhere, all anyone can see is the hash history.</p><p>Why would someone want to use DataLayer and NOT share the files? Many reasons, in three basic situations:</p><ul><li>The data isn’t for sharing. Recording the hashes on DataLayer will let you prove what data you had, when you had it and whether it had ever changed to a private auditor. That auditor may literally be an auditor, or may be a business partner. There is a huge number of non-Web3 use cases that would benefit from the ability to provide this kind of proof.</li><li>The data isn’t for sharing, yet. You need to be able to prove some data hasn’t changed over time. This is useful in many situations where the timing of a disclosure is important. Also games of chance, where you may want to prove what random seed was used for the game, but only disclose it after the game is complete.</li><li>The data isn’t for sharing publicly. The files can be sent directly from one party to another, or to a select group of others. The recipients can confirm the validity of the data and confirm that any other recipient will receive the exact same data. No other party needs access. This is useful for a group that wants to share data in private without a centrally-managed repository that all members of the group must trust. In this context, there is no requirement even to use http.</li></ul><p>As always, data is readily copied. So even though Alice no longer shares her data publicly, Bob still has a copy of it. Bob can share the files directly with Carol, and Carol can verify that the data in the files Bob provides is correct. Alice, having given the files to Bob, can no longer control who receives them. And Carol can prove she has the correct data without disclosing where she got it.</p><p>And so ends the story of Alice, Bob and Carol. It turned out much longer than I had expected. For those of you that made it this far, thank you. I hope it was useful.</p><h3>Killer Feature: Proofs of Inclusion</h3><p>I mentioned above that the hash stored in the DataLayer singleton is actually the root hash of a Merkle tree. So let’s first describe a Merkle tree, in the context of DataLayer.</p><p>DataLayer data stores are made up of (key, value) pairs. I personally think of the DataLayer data stores as tables, and consider the (key, value) pairs to be rows. A <em>hash function </em>is a function that takes as input some arbitrary data and produces as output a fixed-length value, called the hash value. In a <em>secure hash function</em>, it is impossible to create data that will exactly match a particular output hash value. DataLayer uses the secure hash function SHA-256.</p><p>To form the Merkle tree, we start by concatenating the key and value of each row and calculating the secure hash h(key,value). This is a rowhash. These hashes form the leaves of the tree. Each interior node in the tree is the hash of the concatenated rowhashes of its two children. The root node is the hash that ultimately gets stored on chain.</p><p>A quick visual might help:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/581/1*LrudwLpl32NBnrzccF_hDg.png" /><figcaption>Hashes all the way down.</figcaption></figure><p>So the tree is entirely hashes. There is no actual data stored in the Merkle tree. Any change to any key or value will change the root hash. There is no way for someone to come up with a different row or subtree or even a whole different tree that will produce the same root hash. For more information, <a href="https://en.wikipedia.org/wiki/Merkle_tree">the Wikipedia article on Merkle trees is pretty good</a>.</p><p>The great thing about the Merkle tree is that we can prove that a particular (key, value) pair exists in the tree without knowing the whole tree. All you really need are the peer hashes at each level of the tree up to the root. In this example, we want to prove that row 3 exists in the tree:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/581/1*bwBTXktfTMvrhVmwFLjUUw.png" /></figure><p>Specifically, we want to prove that the hash of row 3 (in blue) is in the tree. To do so, we need to provide the hash of row 4 and the hash of the subtree that includes rows 1 and 2 (both in yellow). With that information, we can compute the root. If the computed root matches the one on chain, we can be certain that row 3 is in the tree. This is a <em>proof of inclusion</em>.</p><p>Why do we care about proofs of inclusion? Because the Datalayer singleton can execute them on chain. That’s a big deal. The DataLayer singleton smart contract already has the root hash, so simply providing the rowhash to prove and the necessary peer hashes up the tree allows it to verify that the given rowhash exists in the tree.</p><p>That enables any data in a DataLayer table to be provided to a smart contract on chain and validated so that it can be used by the smart contract, without having to store all the data directly on chain.</p><p>There are a huge number of things you can do with this capability, and I look forward to more of them becoming available over time. For now, we have one DataLayer feature that uses it…</p><h3>Proofs of Inclusion: Two-Party Commit</h3><p>One of the features of Chia that really sets it apart among blockchains is <em>offer files</em>. Offer files allow you to make an offer to trade: you offer to give one asset in exchange for receiving another. You then sign the offer, and make the offer available on the Internet. Anyone that likes the proposed trade can download the offer, attach the asset you had wanted to receive, sign it and submit it to the blockchain to get the asset you had offered. Once one person takes the offer, it is no longer valid, and no one else in the world can use it. The assets exchanged this way can be coins, like XCH or stablecoins, or they can be NFTs or any other asset on chain.</p><p>In centralized databases, you have the ability to queue up multiple updates to the database and commit them all at once, so that either all of the updates are recorded successfully, or none of the updates are recorded at all. Imagine recording a bank transfer: you wouldn’t want to deduct the money from one account without also adding the same amount to the other account. In database terms, recording an update of several tables at once this way is called committing a transaction.</p><p>With DataLayer proofs of inclusion plus Chia offer files, you can truly own your data and still participate in coordinated database updates.</p><p>For example, Alice and Bob each have a DataLayer table. Alice wants to propose an update to both tables. So she creates an offer file that contains:</p><ul><li>An update to her own table to add a new row (potentially also including deleting some prior row that had the same key)</li><li>A proof of inclusion of that new row in the table</li><li>A demand for a proof of inclusion of the row that Alice will require from Bob</li></ul><p>At this point, nothing has happened on chain. Alice’s DataLayer table does not include the new row. Instead, she packages all of the above into an offer file and sends it to Bob.</p><p>Bob opens the offer file and sees the contents. He decides to accept the offer. So he attaches an update to his own DataLayer table and creates a proof of inclusion of that updated row that satisfies Alice’s demand. Now he submits the whole thing to the blockchain, and both tables get updated. Alice can see on chain when the update to her table gets committed and knows that Bob’s data has also been updated as requested.</p><p>This is tremendously valuable for using DataLayer in any multiparty system. In a supply chain, goods can be marked ‘delivered’ by one party if and only if the other party marks them ‘received’. A contract can be signed by having all parties record the same copy of the contract. Decentralized game players can have richer interactions than simply trading goods.</p><p>Here’s a thought experiment: what if one side of the offer file was cryptocurrency instead of a data update? What could you do with the ability to pay for another party to make a specific update to their data?</p><p>Here’s another thought experiment: what if, in a single spendbundle, the Datalayer singleton announces a proof of inclusion of a rowhash, and another smart coin accepts in its solution the key and value for that row? That smart coin could prove the given key and value match the rowhash that the DataLayer singleton validated and could then safely use that data to drive functionality in that coin’s smart contract. What could you do with a smart contract that could access data from an arbitrarily large, yet cryptographically validated, dataset?</p><p>More on this and other potential DataLayer capabilities in another article.</p><h3>DataLayer RPCs (as of Chia Reference Wallet 1.7.0)</h3><p>So now you’re excited about the possible capabilities of Chia DataLayer and you understand how it works. The next thing is to understand how to use it.</p><p>First, the <a href="https://docs.chia.net/datalayer-rpc/">reference documentation </a>is the primary source of information about the Chia DataLayer RPC endpoints.</p><p><a href="https://docs.chia.net/datalayer-rpc/">Read the official documentation here.</a></p><p>That document is a reference, and lists each available endpoint but doesn’t really give a good walkthrough of how to use them. So I’ll do my best to provide such an introduction here. Again, this is not official Chia documentation, but my personal attempt to help others to use DataLayer.</p><p>Before you can do anything else, you will need to start the Datalayer service with:</p><pre>chia start data</pre><p>Or, in the UI:</p><p>Settings -&gt; DATALAYER -&gt; Enable DataLayer</p><h4>Publishing Data</h4><p>Before you can publish data, the first thing is to figure out how people will receive it. Right now, the only method directly supported by the Chia reference client is the mini HTTP server included. To use it, you will need to also start the Chia http server:</p><pre>chia start data_layer_http</pre><p>or use the UI:</p><p>Settings -&gt; DATALAYER -&gt; Enable File Propagation Server</p><p>Next, you will need to open an inbound port to that server. By default, it runs on port 8575. That can be changed in config.yaml. Read the manual on your router for setting up the required “port forwarding rules”. Hopefully, you’ll already know how to do the port forwarding from opening port 8444 for your node, right?</p><p>Next, you’ll need to know your inbound IP. There are any number of tools for this, such as <a href="https://www.whatismyip.com/">http://whatismyip.com</a>. Finally, you’ll need to either request a “static IP” (an IP address that never changes) from your internet service provider, or hope that they don’t happen to change your IP. Unfortunately, requesting a static IP usually comes with a significant cost. Alternatively, you could set up with a “dynamic DNS” provider, but that just starts to get even more complicated.</p><p>Please see my public plea above for services to help deal with this situation.</p><p>Assuming you have all that sorted, you can create a DataLayer table with:</p><p><a href="https://docs.chia.net/datalayer-rpc/#create_data_store">create_data_store</a></p><p>(I long ago got in a bad habit of calling the data represented by a DataLayer singleton a “table”. The correct term is “data store”. Please accept my apologies for any confusion caused.)</p><p>This will create the singleton with an empty hash. It accepts a fee parameter, since it is submitting a transaction on chain.</p><p>Note that one parameter that is missing is the fingerprint parameter. This is an unfortunate oversight. <strong>All DataLayer calls use whatever key is currently logged-in on the main wallet at the time the call is made.</strong> There is no mechanism at this time to specify which key to use, and you are likely to get into a bad state if the current key changes while you’re using DataLayer.</p><p>create_data_store will return the id of the new data store. At that point, you can call:</p><p><a href="https://docs.chia.net/datalayer-rpc/#get_root">get_root</a></p><p>Pass in the id of the newly-created data store, and one of the returned values will be a boolean indicating whether the root has been confirmed. Wait until the root is confirmed before proceeding.</p><p>You can access a list of the data stores owned by your key by calling:</p><p><a href="https://docs.chia.net/datalayer-rpc/#get_owned_stores">get_owned_stores</a></p><p>Next, assuming you want to announce a URL where people can access your data, you will use:</p><p><a href="https://docs.chia.net/datalayer-rpc/#add_mirror">add_mirror</a></p><p>From DataLayer’s perspective, every announcement of a URL on chain is an announcement of a mirror. Anyone can announce a mirror, whether they are providing the data, are subscribed to the data, or just happen to know where that data can be found.</p><p>add_mirror takes a fee parameter, as it does create a transaction on chain. The same warning about fingerprints and keys applies here as it did for create_data_store.</p><p><a href="https://docs.chia.net/datalayer-rpc/#delete_mirror">delete_mirror</a> and <a href="https://docs.chia.net/datalayer-rpc/#get_mirrors">get_mirrors</a> work as you would expect. get_mirrors is the only way to tell when add_mirror completes. Until it is confirmed on chain, the new mirror does not show up in get_mirrors.</p><p>Finally, to actually publish data, you will use:</p><p><a href="https://docs.chia.net/datalayer-rpc/#batch_update">batch_update</a></p><p>This endpoint accepts a “changelist” which is an array of INSERT and DELETE records. The keys and values for each row are blobs, and must be encoded in hex. Any number of records can be in the array, and the keys and values can be of any size, subject to memory size limitations in your system. As a practical matter, most systems can handle a maximum of 50–100 MB of changes. This endpoint also produces a transaction on chain, and so includes a fee parameter and is subject to the same warning about fingerprints and keys.</p><p>Because the data is stored in binary, any format is acceptable. It can be JSON for structured data documents or PDFs and other less-structured data. Also, the data can be encrypted to limit who can read the data and can be compressed to reduce the storage / bandwidth requirements.</p><p>To know when the update has been confirmed, call get_root. When the transaction is successful, the new root will have confirmed equal to true.</p><h4>Accessing Data</h4><p>To access data you do not own, you will need to call:</p><p><a href="https://docs.chia.net/datalayer-rpc/#subscribe">subscribe</a></p><p>This accepts the id of a data store and will attempt to subscribe to it. There is no transaction on chain. You can optionally provide a list of URLs from which to attempt to access the data. If provided, these URLs are used in addition to any announced mirrors to access the data.</p><p>If there are URLs available from which to access the data that you do not want to use, you can use <a href="https://docs.chia.net/datalayer-rpc/#remove_subscriptions">remove_subscriptions</a> to remove them from the list. This command does not unsubscribe from the data store.</p><p><a href="https://docs.chia.net/datalayer-rpc/#unsubscribe">unsubscribe</a> stops fetching new data for the data store, but it does not remove any data from the local machine. <a href="https://docs.chia.net/datalayer-rpc/#subscriptions">subscriptions</a> gets the current list of subscriptions.</p><p>Once subscribed, to see the history of data for a particular data store, you can use:</p><p><a href="https://docs.chia.net/datalayer-rpc/#get_root_history">get_root_history</a></p><p>This will return all of the recorded hash roots for a specific DataLayer data store. Alternatively, you can use:</p><p><a href="https://docs.chia.net/datalayer-rpc/#get_roots">get_roots</a></p><p>To get the latest roots for a collection of data stores.</p><p>You can access the data with:</p><p><a href="https://docs.chia.net/datalayer-rpc/#get_keys_values">get_keys_values</a></p><p><a href="https://docs.chia.net/datalayer-rpc/#get_keys">get_keys</a></p><p><a href="https://docs.chia.net/datalayer-rpc/#get_value">get_value</a></p><p>These do what you’d expect. get_keys_values is dangerous as it returns every key and every value in the data store at once. There is no way to tell in advance how large that may be. The keys and values are hex-encoded, and so are much larger in the response payload than the actual data they represent. It is much safer to call get_keys to get all the keys and then call get_value on the keys of interest.</p><p>All of get_keys_values, get_keys and get_value return <em>the latest data that has been received.</em> They do not return the root hash associated with that data, so there is the danger that you receive stale data. To address this, you can pass in a specific root_hash parameter to each of them to specify that you want the data for a specific root hash. There will always be a delay between detecting an updated hash on chain and receiving the corresponding data (if you’re able to access the corresponding data at all). If you request data for a root hash that you don’t yet have, you will get an error.</p><p>Finally, you can use:</p><p><a href="https://docs.chia.net/datalayer-rpc/#get_kv_diff">get_kv_diff</a></p><p>This will get the rows changed between any pair of hash roots for a particular data store. Note that what is returned is the net change, so any rows that were both added and deleted, or deleted then added, between the two given hash roots will not show up as diffs in the output.</p><p>Sequentially calling get_kv_diff on each adjacent pair of root hashes will provide the exact history for a data store.</p><h4>Offers and Two Party Commits</h4><p>The high-level process for using DataLayer offers is straightforward: the maker makes an offer file with:</p><p><a href="https://docs.chia.net/datalayer-rpc/#make_offer">make_offer</a></p><p>and sends it to the taker. Unlike regular offer files, there can only be one taker — the owner of the DataLayer singleton that needs to complete the offer.</p><p>The taker can then verify the offer with:</p><p><a href="https://docs.chia.net/datalayer-rpc/#verify_offer">verify_offer</a></p><p>This will make sure the offer file is valid. The verification step is entirely optional.</p><p>Finally, the taker can accept the offer with:</p><p><a href="https://docs.chia.net/datalayer-rpc/#take_offer">take_offer</a></p><p>This will first check that the offer file is valid, then make any updates to the data store(s) specified for the taker in the file, and finally submit it to the blockchain.</p><p>Note that none of the DataLayer offer RPCs have CLI equivalents. To call them from the CLI you will need to use:</p><p>chia rpc data_layer make_offer &lt;JSON request body | -j request.json&gt;</p><p>Now let’s take a look at what DataLayer offer files actually do. Here is an example request body for make_offer:</p><pre>{ &quot;maker&quot;: [<br>    { &quot;store_id&quot;: &quot;e76f1aa5a983531580c1c13b1b11dd508b9261dce7b1a009ca2af1e5e92652c3&quot;,<br>      &quot;inclusions&quot;: [<br>        { &quot;key&quot;: &quot;48656c6c6f&quot;,<br>          &quot;value&quot;: &quot;576f726c6421&quot;<br>        }<br>      ]<br>    }<br>  ],<br>  &quot;taker&quot;: [<br>    { &quot;store_id&quot;: &quot;0ba3e6573d9e1356f87ac59f4980e25d736d0614276e23bbc56a2df6c09d811b&quot;,<br>      &quot;inclusions&quot;: [<br>        { &quot;key&quot;: &quot;48656c6c6f&quot;,<br>          &quot;value&quot;: &quot;576f726c6421&quot;<br>        }<br>      ]<br>    }<br>  ],<br>  &quot;fee&quot;: 1000000<br>}</pre><p>Here we see that there are two sections: one for the maker and one for the taker. The maker side lists the proofs of inclusion that the maker is going to provide. The taker side lists the proofs of inclusion that the taker must provide to complete the offer and submit it to the chain.</p><p>Each section has an array of store ids. Each side of the offer can include as many proofs of inclusion as needed for as many data stores as needed. For each data store, there is an array of inclusions. These are the proofs being offered or required. Each proof includes the cleartext (hex) key and value of row being proven.</p><p>Finally, there is a fee. This is the maker fee that will be included in the offer, in mojos.</p><p>The maker must be subscribed to the taker’s singleton(s) to call make_offer. However, the maker does not need to actually have the data.</p><p>The response from make_offer looks something like this:</p><pre>{<br>    &quot;offer&quot;: {<br>        &quot;maker&quot;: [<br>            {<br>                &quot;proofs&quot;: [<br>                    {<br>                        &quot;key&quot;: &quot;48656c6c6f&quot;,<br>                        &quot;layers&quot;: [<br>                            {<br>                                &quot;combined_hash&quot;: &quot;dea970ce50eea5d936d55684a90ba66be3bce60d20140ca3fc23d578332c061a&quot;,<br>                                &quot;other_hash&quot;: &quot;adc91718ace34b8a2f6faaf226a36714c88f932d3bbf886502fc88f8d6007f17&quot;,<br>                                &quot;other_hash_side&quot;: &quot;right&quot;<br>                            }<br>                        ],<br>                        &quot;node_hash&quot;: &quot;509ed575992c34140b77ee226421ed2c67606bd5fd26763f45fb804bb6f47773&quot;,<br>                        &quot;value&quot;: &quot;576f726c6421&quot;<br>                    }<br>                ],<br>                &quot;store_id&quot;: &quot;e76f1aa5a983531580c1c13b1b11dd508b9261dce7b1a009ca2af1e5e92652c3&quot;<br>            }<br>        ],<br>        &quot;offer&quot;: &quot;000000040000000000...cd28f7cfaeb6c4473ce6cc&quot;,<br>        &quot;taker&quot;: [<br>            {<br>                &quot;inclusions&quot;: [<br>                    {<br>                        &quot;key&quot;: &quot;48656c6c6f&quot;,<br>                        &quot;value&quot;: &quot;576f726c6421&quot;<br>                    }<br>                ],<br>                &quot;store_id&quot;: &quot;0ba3e6573d9e1356f87ac59f4980e25d736d0614276e23bbc56a2df6c09d811b&quot;<br>            }<br>        ],<br>        &quot;trade_id&quot;: &quot;e7423eb210b373fe8c271c190f210c6316daeddaca1cf5b307a50d6194fd8be1&quot;<br>    },<br>    &quot;success&quot;: true<br>}</pre><p>This is the offer file with the exception that the final &quot;success&quot;: true needs to be removed.</p><p>Let’s break down what is in this offer file:</p><ul><li>Again there are two sides: the maker and the taker.</li><li>The offer section will be a very, very long hex stream. This is the actual on chain offer (spendbundle). Both verify_offer and take_offer will confirm that the hex offer matches the surrounding human-readable JSON.</li><li>The trade_id is for tracking the transaction.</li></ul><p>The maker section includes an array derived from the inclusions section of the maker’s request, each element of the array includes a store_id and some number of proofs.</p><p>Each proof is exactly what you’d expect, given that the data is stored in a Merkle tree. The cleartext hex key and value, the nodehash of the (key, value) pair, and then for each level of the Merkle tree from the node to the tree root there is a record specifying the peer hash (other_hash), which side the peer hash is on (other_hash_side) and the result of hashing the concatenation of the two (combined_hash). The top-level combined_hash is the Merkle root of the data store when the proofs of inclusion run on chain.</p><p>Using this json file, the taker can clearly see what the maker is offering, and what the maker is requesting.</p><p>Note that creating the offer file does not necessarily mean that the maker has to update their data store(s) at all. If the rows for which proofs of inclusion will be provided in the offer file already exist in the maker’s DataLayer tables, then there is no update to the maker’s data store.</p><p>Also note that the maker does not provide INSERTS and DELETES, but instead only provides proofs of rows that will exist when the offer is successfully completed. There is no way to use proofs of inclusion to prove that a specific row does <em>not</em> exist in the table, except by proving that a different row exists with the same key. If the maker creates an offer with a proof for a row with the same key as one that already exists, it is treated as both a DELETE of the existing row and an INSERT of the new row.</p><p>The maker sends the offer file (with &quot;success&quot;: true removed) to the taker. The taker can inspect it and know exactly what rows the maker is offering to prove, and what rows the taker is expected to prove.</p><p>To make the offer usable, the taker must attach an entry to the end for the fee they plan to include when submitting to the chain. This can be zero. So where the maker had &quot;success&quot;: true, the taker will insert &quot;fee&quot;: 0. Again, the fee is in mojos.</p><p>The taker can first call verify_offer to make sure the offer file is valid. The body of the request is the offer, including fee. In response, the taker will get something like this:</p><pre>{<br>    &quot;error&quot;: null,<br>    &quot;fee&quot;: 100000,<br>    &quot;success&quot;: true,<br>    &quot;valid&quot;: true<br>}</pre><p>Assuming the taker wants to accept the offer, they will submit it to the chain with take_offer, where the body of the request is the offer. The response will look something like this:</p><pre>{<br>    &quot;success&quot;: true,<br>    &quot;trade_id&quot;: &quot;b008ea60a001b4557f49d13029f9d0d533eb78ad4fad8c8501ae631c9179b958&quot;<br>}</pre><p>The taker also doesn’t necessarily have to make an update to their data stores. If the needed rows already exist, then taking the offer simply creates the needed proofs of inclusion, with no update to the root stored on chain.</p><p>At this time, there is no reliable way to tell when the offer submitted by the taker is confirmed on chain. If taking the offer involves updating the taker’s root hash, then using get_root or get_root_history will be a good proxy to see when the transaction is confirmed.</p><p>While the offer is pending, the maker will not be able to make further updates to any data store(s) involved in the outstanding offer(s). To cancel an offer, the maker can use:</p><p><a href="https://docs.chia.net/datalayer-rpc/#cancel_offer">cancel_offer</a></p><p>This will cancel the offer. The trade_id from the original offer file is used to identify the offer to cancel. Like canceling other kinds of Chia offers, there is an insecure option that just tells Chia to forget about the offer. The taker could still take the offer if they received the offer file and choose to accept it later. There is also a secure option that actually invalidates the offer by spending one of the DataLayer coins involved in the offer. This requires a blockchain transaction and potentially a fee, but ensures that the offer cannot be subsequently taken. Using the insecure version of cancel and immediately updating the data store on chain will also securely cancel the outstanding offer.</p><h3>Conclusion</h3><p>I hope this article has been useful. I called it a “Primer” both because it is a useful place to start when working with DataLayer, and because I hope that it “primes the pump” and helps to get people using it.</p><p>At the top of this article, I had proposed a number of reasons why DataLayer was different from other ways of managing data. To conclude, I’d like to review those points and more clearly explain them:</p><ul><li><strong>You Own Your Data</strong>. The DataLayer singleton is a coin like any other on the blockchain, and custody of that coin is custody of your data.</li><li><strong>Censorship Resistance</strong>. Once DataLayer hosting services become available in multiple jurisdictions, it will be incredibly difficult if not impossible to censor DataLayer.</li><li><strong>Peer-to-peer</strong>. Anyone can host DataLayer data anywhere, and subscribers to that data get it directly from wherever it is hosted.</li><li><strong>Auditability</strong>. For every Merkle root recorded on the blockchain, there is a data file that can be proven to exactly match it. Each root is recorded at a specific block height when the DataLayer singleton was spent, proving when that data file was committed by the owner.</li><li><strong>Accountability</strong>. Every DataLayer singleton is associated with a single key. The owner of that key cannot escape the data that they previously published.</li><li><strong>Durability</strong>. Anyone can host a mirror of the data associated with a DataLayer singleton. With more mirrors, the data rapidly becomes more durable. If that data is important to you in any way, you can ensure it survives by hosting a mirror.</li><li><strong>Privacy</strong>. Chia DataLayer data is not shared by default. You have to actively announce a mirror to share it. The default mechanism for sharing data is http, for which there are many systems available to restrict access by username/password, certificate, source IP, token, etc.</li><li><strong>Smart Contracts</strong>. DataLayer proofs of inclusion allow smart contracts to validate cryptographically-signed data without having all of that data stored directly on the blockchain. That data is already accessible in offer files, and in the future will be made available to smart contracts in other ways as well.</li></ul><p>There are a thousand things I can think of to do with DataLayer, and I’m sure I’m just scratching the surface. I look forward to seeing what the community does with it. I hope to write many more articles on DataLayer and some of the other technologies on Chia with which I’m intimately familiar. Please let me know if there is anything in particular you’d like me to address.</p><p>Please post questions, comments, requests for clarifications and the like here. I will monitor and reply as best I can.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e4a4796c390e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>