From 0c1e8aa6627cba4c6eb887d9a2205cb227a44e96 Mon Sep 17 00:00:00 2001 From: Rigidity Date: Tue, 26 Sep 2023 14:10:39 -0400 Subject: [PATCH] Initial code examples --- docs/primitives/cats.md | 24 ++++++++++++++++++++++++ docs/primitives/dids.md | 16 ++++++++++++++++ docs/primitives/nfts.md | 18 ++++++++++++++++++ docs/primitives/offers.md | 14 ++++++++++++++ docs/primitives/singletons.md | 15 +++++++++++++++ docs/primitives/standard-transactions.md | 21 +++++++++++++++++++++ 6 files changed, 108 insertions(+) diff --git a/docs/primitives/cats.md b/docs/primitives/cats.md index 16432726..08c0228c 100644 --- a/docs/primitives/cats.md +++ b/docs/primitives/cats.md @@ -19,6 +19,30 @@ To learn more about the terminology used on this page, check out the [blog entry Additionally, fungible tokens can be split apart and merged together, whereas non-fungible tokens are indivisible. +## Code Examples + +### chia-blockchain + +The official Chia wallet has a reference implementation for the following in Python: + +- [Spend CAT coins](https://github.com/Chia-Network/chia-blockchain/blob/010cedf83718aa8e4d97da76f892fe69387a5d82/chia/wallet/cat_wallet/cat_wallet.py#L784) + +### chia-rs + +The wallet code used by the [MonsterSprouts example game](https://github.com/Chia-Network/MonsterSprouts) has the following reference methods: + +- [Puzzle and solution types](https://github.com/Chia-Network/chia_rs/blob/wallet-dev/chia-primitives/src/primitives/cat.rs) +- [Issue new CAT](https://github.com/Chia-Network/chia_rs/blob/2334c842f694444da317fa7432f308f159f62d70/chia-wallet/src/wallet.rs#L209) +- [Spend CAT coins](https://github.com/Chia-Network/chia_rs/blob/2334c842f694444da317fa7432f308f159f62d70/chia-wallet/src/wallet.rs#L545) +- [Send CATs to puzzle hash](https://github.com/Chia-Network/chia_rs/blob/2334c842f694444da317fa7432f308f159f62d70/chia-wallet/src/wallet.rs#L399) + +### chia-wallet-lib + +The [Chia wallet library NPM package](https://github.com/Chia-Network/node-chia-wallet-lib) has the following reference implementation: + +- [Issue new CAT](https://github.com/Chia-Network/node-chia-wallet-lib/blob/6c8d564538be121079596e492fa0da497c9dd39c/src/types/puzzles/AssetToken.ts#L63) +- [Spend CAT coins](https://github.com/Chia-Network/node-chia-wallet-lib/blob/6c8d564538be121079596e492fa0da497c9dd39c/src/types/puzzles/AssetToken.ts#L102) + ## CAT Code {#code} This is the source code of the CAT, which can also be found in the chia-blockchain repository in the puzzle [`cat_v2.clvm`](https://github.com/Chia-Network/chia-blockchain/blob/fad414132e6950e79e805629427af76bf9ddcbc5/chia/wallet/puzzles/cat_v2.clvm): diff --git a/docs/primitives/dids.md b/docs/primitives/dids.md index 69ad8cc0..66b6df2f 100644 --- a/docs/primitives/dids.md +++ b/docs/primitives/dids.md @@ -7,6 +7,22 @@ DIDs are a decentralized way to represent an identity, be that an organization o More functionality will be added to the DID standard in the future, allowing for easier identification and recovery methods. +## Code Examples + +### chia-blockchain + +The official Chia wallet has a reference implementation for the following in Python: + +- [Mint new DID](https://github.com/Chia-Network/chia-blockchain/blob/010cedf83718aa8e4d97da76f892fe69387a5d82/chia/wallet/did_wallet/did_wallet.py#L1217) +- [Create update DID spend](https://github.com/Chia-Network/chia-blockchain/blob/010cedf83718aa8e4d97da76f892fe69387a5d82/chia/wallet/did_wallet/did_wallet.py#L534) + +### chia-rs + +The wallet code used by the [MonsterSprouts example game](https://github.com/Chia-Network/MonsterSprouts) has the following reference methods: + +- [Puzzle and solution types](https://github.com/Chia-Network/chia_rs/blob/wallet-dev/chia-primitives/src/primitives/did.rs) +- [Spend DID](https://github.com/Chia-Network/chia_rs/blob/2334c842f694444da317fa7432f308f159f62d70/chia-wallet/src/wallet.rs#L1148) + ## DID Code {#code} This is the source code of the DID inner puzzle, which can also be found in the chia-blockchain repository in the puzzle [`did_innerpuz.clvm`](https://github.com/Chia-Network/chia-blockchain/blob/164fd158c8626893bc45ba00b87ae69d2ab5f8b7/chia/wallet/puzzles/did_innerpuz.clvm). diff --git a/docs/primitives/nfts.md b/docs/primitives/nfts.md index 603ec865..ad754018 100644 --- a/docs/primitives/nfts.md +++ b/docs/primitives/nfts.md @@ -7,6 +7,24 @@ NFTs are non-fungible tokens that are minted on the Chia blockchain. The NFT puz They can be used to prove digital ownership of files such as images or videos, as well as the metadata and license pertaining to the file. +## Code Examples + +### chia-blockchain + +The official Chia wallet has a reference implementation for the following in Python: + +- [Mint NFT](https://github.com/Chia-Network/chia-blockchain/blob/010cedf83718aa8e4d97da76f892fe69387a5d82/chia/wallet/nft_wallet/nft_wallet.py#L321) +- [Bulk mint NFTs](https://github.com/Chia-Network/chia-blockchain/blob/010cedf83718aa8e4d97da76f892fe69387a5d82/chia/wallet/nft_wallet/nft_wallet.py#L1242) +- [Spend NFT](https://github.com/Chia-Network/chia-blockchain/blob/010cedf83718aa8e4d97da76f892fe69387a5d82/chia/wallet/nft_wallet/nft_wallet.py#L606) + +### chia-rs + +The wallet code used by the [MonsterSprouts example game](https://github.com/Chia-Network/MonsterSprouts) has the following reference methods: + +- [Puzzle and solution types](https://github.com/Chia-Network/chia_rs/blob/wallet-dev/chia-primitives/src/primitives/nft.rs) +- [Bulk mint NFTs](https://github.com/Chia-Network/chia_rs/blob/wallet-dev/chia-wallet/src/wallet.rs#L665) +- [Spend NFT](https://github.com/Chia-Network/chia_rs/blob/2334c842f694444da317fa7432f308f159f62d70/chia-wallet/src/wallet.rs#L1053). + ## NFT Code {#code} This is the source code of the NFT state layer, which can also be found in the chia-blockchain repository in the puzzle [`nft_state_layer.clvm`](https://github.com/Chia-Network/chia-blockchain/blob/164fd158c8626893bc45ba00b87ae69d2ab5f8b7/chia/wallet/puzzles/nft_state_layer.clvm). diff --git a/docs/primitives/offers.md b/docs/primitives/offers.md index 1a0473e8..5bd35c23 100644 --- a/docs/primitives/offers.md +++ b/docs/primitives/offers.md @@ -5,6 +5,20 @@ slug: /offers Offers are a way to enable peer-to-peer asset exchange on the Chia blockchain. In other words, you can swap tokens without needing to go through an exchange. Only two parties are required, the maker and the taker. They don't need to trust each other, since any attempts to modify the offer will invalidate it. +## Code Examples + +### chia-blockchain + +The official Chia wallet has a reference implementation for the following in Python: + +- [Offer multiple assets](https://github.com/Chia-Network/chia-blockchain/blob/010cedf83718aa8e4d97da76f892fe69387a5d82/chia/wallet/trade_manager.py#L410) + +### chia-rs + +The wallet code used by the [MonsterSprouts example game](https://github.com/Chia-Network/MonsterSprouts) has the following reference methods: + +- [Offer NFT1 for CAT2](https://github.com/Chia-Network/chia_rs/blob/2334c842f694444da317fa7432f308f159f62d70/chia-wallet/src/wallet.rs#L101) + ## Offer Files When you create an offer, you get a string of text that is usually stored in a file. This describes the details of the trade, including the assets you are requesting and the assets you are giving in return. This file can be published on various platforms and downloaded by anyone to fulfill in the wallet of their choice. This allows for the flexibility of exchanges, while keeping it fully decentralized and preventing tampering or relying on a third party or middleman. diff --git a/docs/primitives/singletons.md b/docs/primitives/singletons.md index 1f258678..9a70eb92 100644 --- a/docs/primitives/singletons.md +++ b/docs/primitives/singletons.md @@ -5,6 +5,21 @@ slug: /singletons Singletons allow you to keep track of the state of something on the blockchain, with the ability to verify and check any part of its history using a unique id. It proves that the puzzle is unique and cannot be duplicated. Singletons can use any arbitrary inner puzzle, and is used to make NFTs, DIDs, the pooling puzzle, and many other things possible. +## Code Examples + +### chia-blockchain + +The official Chia wallet has a reference implementation for the following in Python: + +- [Create singleton solution](https://github.com/Chia-Network/chia-blockchain/blob/e07f9196ffd8fcb6d6e7e9dc9079f2bb9bcfe464/chia/wallet/nft_wallet/nft_wallet.py#L777) + +### chia-rs + +The wallet code used by the [MonsterSprouts example game](https://github.com/Chia-Network/MonsterSprouts) has the following reference methods: + +- [Puzzle and solution types](https://github.com/Chia-Network/chia_rs/blob/wallet-dev/chia-primitives/src/primitives/singleton.rs) +- [Create singleton solution](https://github.com/Chia-Network/chia_rs/blob/2334c842f694444da317fa7432f308f159f62d70/chia-wallet/src/wallet.rs#L1130) + ## Singleton Code {#code} This is the source code of the singleton, which can also be found in the chia-blockchain repository in the puzzle [`singleton_top_layer_v1_1.clvm`](https://github.com/Chia-Network/chia-blockchain/blob/8b70466a70388d0fff437d138192ba38faf92be8/chia/wallet/puzzles/singleton_top_layer_v1_1.clvm). diff --git a/docs/primitives/standard-transactions.md b/docs/primitives/standard-transactions.md index 64d26888..13243150 100644 --- a/docs/primitives/standard-transactions.md +++ b/docs/primitives/standard-transactions.md @@ -9,6 +9,27 @@ The standard transaction is a puzzle used by the Chia wallet to generate its add Before you read this page, it may be worth checking out this [Agg Sigs, Taproot, and Graftroot blog post](https://www.chia.net/2021/05/27/Agrgregated-Sigs-Taproot-Graftroot.html) by Bram Cohen on why the standard transaction is the way it is. ::: +## Code Examples + +### chia-blockchain + +The official Chia wallet has a reference implementation for the following in Python: + +- [Spend standard transaction](https://github.com/Chia-Network/chia-blockchain/blob/e07f9196ffd8fcb6d6e7e9dc9079f2bb9bcfe464/chia/wallet/wallet.py#L421) + +### chia-rs + +The wallet code used by the [MonsterSprouts example game](https://github.com/Chia-Network/MonsterSprouts) has the following reference methods: + +- [Puzzle and solution types](https://github.com/Chia-Network/chia_rs/blob/wallet-dev/chia-primitives/src/primitives/standard_puzzle.rs) +- [Spend standard transaction](https://github.com/Chia-Network/chia_rs/blob/2334c842f694444da317fa7432f308f159f62d70/chia-wallet/src/wallet.rs#L1166) + +### chia-wallet-lib + +The [Chia wallet library NPM package](https://github.com/Chia-Network/node-chia-wallet-lib) has the following reference implementation: + +- [Spend standard transaction](https://github.com/Chia-Network/node-chia-wallet-lib/blob/6c8d564538be121079596e492fa0da497c9dd39c/src/types/puzzles/StandardTransaction.ts#L27) + ## Terminology **Hidden Puzzle** -