Skip to content

Commit

Permalink
Merge pull request #387 from Chia-Network/cat_tutorial
Browse files Browse the repository at this point in the history
Refresh CAT creation tutorial
  • Loading branch information
danieljperry authored Oct 4, 2023
2 parents d405d35 + 1fe8219 commit 207582a
Show file tree
Hide file tree
Showing 27 changed files with 1,105 additions and 120 deletions.
122 changes: 104 additions & 18 deletions docs/cli-reference/cat-admin.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ This document is a reference guide for Chia's CAT Admin Tool, located in the [CA

To set up your environment (including installing this tool), follow our [CAT Creation Tutorial](/guides/cat-creation-tutorial).

If you want to use this tool to reissue CAT1, then follow our [CAT2 Token Reissuance guide](/guides/cat2-issuance).

## Reference

### `cats`
Expand All @@ -27,22 +25,27 @@ Usage: cats [OPTIONS]

Options:

| Short Command | Long Command | Type | Required | Description |
| :------------ | :------------ | :------ | :------- | :--------------------------------------------------------------------------------- |
| -l | --tail | TEXT | True | The TAIL program to launch this CAT with |
| -c | --curry | TEXT | False | An argument to curry into the TAIL |
| -s | --solution | TEXT | True | The solution to the TAIL program [default: ()] |
| -t | --send-to | TEXT | True | The address these CATs will appear at once they are issued |
| -a | --amount | INTEGER | True | The amount to issue in mojos (regular XCH will be used to fund this) |
| -m | --fee | INTEGER | True | The fees for the transaction, in mojos [default: 0] |
| -f | --fingerprint | INTEGER | False | The wallet fingerprint to use as funds |
| -sig | --signature | TEXT | False | A signature to aggregate with the transaction |
| -as | --spend | TEXT | False | An additional spend to aggregate with the transaction |
| -b | --as-bytes | None | False | Output the spend bundle as a sequence of bytes instead of JSON |
| -sc | --select-coin | None | False | Stop the process once a coin from the wallet has been selected and return the coin |
| -q | --quiet | None | False | Quiet mode will not ask to push transaction to the network |
| -p | --push | None | False | Automatically push transaction to the network in quiet mode |
| | --help | None | False | Show a help message and exit |
| Short Command | Long Command | Type | Required | Description |
| :------------ | :-------------------- | :------ | :------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| -l | --tail | TEXT | True | The TAIL program to launch this CAT with |
| -c | --curry | TEXT | False | An argument to curry into the TAIL |
| -s | --solution | TEXT | False | The solution to the TAIL program [default: ()] |
| -t | --send-to | TEXT | True | The address these CATs will appear at once they are issued |
| -a | --amount | INTEGER | True | The amount to issue in mojos (regular XCH will be used to fund this) |
| -m | --fee | INTEGER | False | The fees for the transaction, in mojos [default: 0] |
| -d | --authorized-provider | TEXT | False | A trusted DID that can issue VCs that are allowed to trade the CAT. Specifying this option will make the CAT a CR (credential restricted) CAT. Requires specifying either `--proofs-checker` or `--cr-flag` |
| -r | --proofs-checker | TEXT | False | The program that checks the proofs of a VC for a CR-CAT. Specifying this option requires a value for `--authorized-providers` |
| -v | --cr-flag | TEXT | False | Specify a list of flags to check a VC for in order to authorize this CR-CAT. Specifying this option requires a value for `--authorized-providers`. Cannot be used if a custom `--proofs-checker` is specified. |
| -f | --fingerprint | INTEGER | False | The wallet fingerprint to use as funds |
| -sig | --signature | TEXT | False | A signature to aggregate with the transaction |
| -as | --spend | TEXT | False | An additional spend to aggregate with the transaction |
| -b | --as-bytes | None | False | Output the spend bundle as a sequence of bytes instead of JSON |
| -sc | --select-coin | None | False | Stop the process once a coin from the wallet has been selected and return the coin |
| -q | --quiet | None | False | Quiet mode will not ask to push transaction to the network |
| -p | --push | None | False | Automatically push transaction to the network in quiet mode |
| | --root-path | PATH | False | The root folder where the config lies [default: ~/.chia/mainnet] |
| | --wallet-rpc-port | INTEGER | False | The RPC port the wallet service is running on |
| | --help | None | False | Show a help message and exit |

<details>
<summary>Example 1 - select a coin from the wallet with a value of at least 1 XCH (1 trillion mojos)</summary>
Expand Down Expand Up @@ -90,6 +93,89 @@ After pushing the transaction, the new ID and Eve Coin (singleton parent coin) w

</details>

<details>
<summary>Example 3 - Mint a new CR-CAT</summary>

First, select a coin to use for the minting. Flags included in this example (CR-specific flags are in **bold**):
* `--tail`: The tail to use; in this case we'll use a single-issuance TAIL
* `--send-to`: The address to send the CR-CATs to upon minting
* **`--authorized-provider`: The DID that is authorized to issue VCs containing the required proof(s) for this CAT**
* **`--cr-flag`: The proof(s) required for owning this CR-CAT**
* `--amount`: The number of mojos for this issuance (1 million mojos = 1 thousand CR-CATs)
* `-m`: The transaction fee, in mojos
* `--as-bytes`: Use bytes instead of JSON
* `--select-coin`: Instead of minting the CAT, just select a coin to use for the isuance

```bash
cats --tail ./reference_tails/genesis_by_coin_id.clsp.hex --send-to txch1ek6ln2ejdsec6l734x8tggk9j5sepl8nfqjer5yt2dr905f04prqmcjcc5 --authorized-provider did:chia:1x23lnyd2xjefnfly075ngk79duf0yxna35cp86mgnnp4t33senfs4cah7u --cr-flag "test_proof1" --amount 1000000 -m 1000 --as-bytes --select-coin
```

Response:

```bash
{
"amount": 999694993543,
"parent_coin_info": "0x3ad9ec3ab9039047106476b4b23d05c46a7f02a6114c4eaf82792c3229e74416",
"puzzle_hash": "0xa8180f3997eeda1804508c1f4dbe55ef17808fe2df970bba408807b10e7dd9ba"
}
Name: c5519ac8ef55043b23bef45b1326d445f2c4af579f13dc0cdec10335ccb0a809
```

In the above repsonse, `Name` is the ID of the coin to be used for the minting. Next, run the same command again, but remove the `--select-coin` flag and add `--curry 0x<coin ID>` (the `0x` is required and important here):

```bash
cats --tail ./reference_tails/genesis_by_coin_id.clsp.hex --send-to txch1ek6ln2ejdsec6l734x8tggk9j5sepl8nfqjer5yt2dr905f04prqmcjcc5 --authorized-provider did:chia:1x23lnyd2xjefnfly075ngk79duf0yxna35cp86mgnnp4t33senfs4cah7u --cr-flag "test_proof1" --amount 1000000 -m 1000 --as-bytes --curry 0xc5519ac8ef55043b23bef45b1326d445f2c4af579f13dc0cdec10335ccb0a809
```

Response:

```bash
Successfully pushed the transaction to the network
Asset ID: 262a2c2cbb09414652006c4da139a186b3a110bb57cd5d76b6785e4811f1c77c
Eve Coin ID: 692a4f63c56815a33510088a255d695aea472d0f03bb9f0d5cdd5c91a82821f2
```

Just as with standard CATs, the CR-CAT has been minted and sent to its destination address. `Asset ID` can now be added in the destination wallet.

In this case, the destination wallet is the holder of a VC with the proof required to hold this CR-CAT. To verify this, run the `vcs get` CLI command:

```bash
chia wallet vcs get
```

```bash
Proofs:
- f063e22557705b14425b8fca60018796b4364eb6354f45d0b99431a71d3043e5
- test_proof1
- test_proof2

Launcher ID: 1e3cd9da1d4545700c8c26fb7ba452cf28b1c7d78b5fa7434307d32a435718c8
Coin ID: addf46fac52aac510b31a7dc025528411b5013d89c81174f4726b63a5dc0d395
Inner Address: txch166pzqd55p2emp9sqaflvyc8x2s4qn4eexrxgrlfwf8khuefp5fqswe84mu
Proof Hash: f063e22557705b14425b8fca60018796b4364eb6354f45d0b99431a71d3043e5
```

This VC contains the proof that was added to the CR-CAT (`test_proof1`). Once the CR-CAT has been added to this Chia wallet, it will be displayed as type `CRCAT`. For example:

```bash
chia wallet show
```

Response:

```bash
CAT 262a2c2cbb094146...:
-Total Balance: 1000.0 (1000000 mojo)
-Balance Pending VC Approval: 0.0 (0 mojo)
-Pending Total Balance: 1000.0 (1000000 mojo)
-Spendable: 1000.0 (1000000 mojo)
-Type: CRCAT
-Asset ID: 262a2c2cbb09414652006c4da139a186b3a110bb57cd5d76b6785e4811f1c77c
-Wallet ID: 5
```

</details>

---

### `secure_the_bag`
Expand Down
Loading

0 comments on commit 207582a

Please sign in to comment.