git.delta.rocks / unique-network / refs/commits / 7ca598f7f6b8

difftreelog

source

doc/demo_milestone1-2.md7.8 KiBsourcehistory
1# Manual Demos23Milestone 1 and 2 deliverables are marked by tag [release1](https://github.com/usetech-llc/nft_parachain/tree/release1)45## Milestone 167### A running chain89**Substrate based blockchain node to host NFT Tracking Module created with substrate-up scripts (currently substrate-up10only support Substrate 1.0)**1112We have created chain based on both versions of substrate: 1 and 2. Nonetheless, the substrate 1 is not being widely13used and we decided to obsolete this branch of code. The code still exists in14[substrate1](https://github.com/usetech-llc/nft_parachain/tree/substrate1) branch, but this delivery document is based15on substrate 2 version.1617The node can be run using docker container:1819```20docker-compose up -d21```2223#### NFT Tracking Module2425Open extrinsics tab of the [standard UI](https://polkadot.js.org/apps/#/extrinsics) and find "nft" in the module list.26This proves that NFT module is deployed.2728#### Balances Module, Other modules included by default2930The [same UI](https://polkadot.js.org/apps/#/extrinsics) allows verification that all other modules are also installed31as needed.3233#### Configuration of runtime as needed (e.g. for hot module updates)3435The `set_code` method worked out of the box and we did not need to perform any additional customizations to upload an36updated WASM version of NFT palette.3738### NFT Tracking Module3940Before we continue, we need to do some preparations in the UI: Add NFT Data types so that the UI knows how to decode41them. Go to [Settings-Developer Tab](https://polkadot.js.org/apps/#/settings/developer) and add following types to the42JSON object in there:4344```45{46  "NftItemType": {47    "Collection": "u64",48    "Owner": "AccountId",49    "Data": "Vec<u8>"50  },51  "CollectionType": {52    "Owner": "AccountId",53    "NextItemId": "u64",54    "CustomDataSize": "u32"55  },56  "Address": "AccountId",57  "LookupSource": "AccountId",58  "Weight": "u32"59}60```6162**Note:** In the future we will likely switch to substrate "2.0.0-alpha.7", in which case Weight type should be `u64`.6364#### CreateCollection6566Before running test, open [chain state tab](https://polkadot.js.org/apps/#/chainstate) and read `nft`.`nextCollectionId`67state variable, which shows how many collections were created so far. If you just started the chain, this should68equal 0.6970Open extrinsics tab of the [standard UI](https://polkadot.js.org/apps/#/extrinsics) and select ALICE account. Select71`nft` module and `createCollection` method. Put 1 in `custom_data_size` and run the transaction. After it is finalized,72read the `nft`.`nextCollectionId` state variable. It will be equal 1.7374Also, read the state variable `nft`.`collection` with ID = 1 (Because everything in NFT Palette is numbered from 1, not75from 0). You will see something like this:7677```78nft.collection: CollectionType79{80  Owner: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY,81  NextItemId: 1,82  CustomDataSize: 183}84```8586### ChangeCollectionOwner8788Open extrinsics tab of the [standard UI](https://polkadot.js.org/apps/#/extrinsics). Select `nft` module and89`changeCollectionOwner` method. First, try to execute it to change owner to BOB for collection 1 from some different90account than ALICE - FERDIE to see that it is not possible because ALICE owns collection 1 and FERDIE is not allowed to91give it to BOB. Second, select ALICE as transaction signer and run it again. This time the collection owner changes,92which will be reflected if you read the state variable `nft`.`collection` with ID = 1:9394```95nft.collection: CollectionType96{97  Owner: 5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty,98  NextItemId: 1,99  CustomDataSize: 1100}101```102103Change the ownership back to ALICE to continue with this demo.104105### DestroyCollection106107**Note: Before destroying collection, you can see Milestone 2 deliverables to avoid creating collection again**108109Run `nft`.`destroyCollection` with collection ID = 1, and then read collection from state. The returned fields will have110default values, which indicates that collection does not exsit anymore:111112```113nft.collection: CollectionType114{115  Owner: 5C4hrfjw9DjXZTzV3MwzrrAr9P1MJhSrvWGWqi1eSuyUpnhM,116  NextItemId: 0,117  CustomDataSize: 0118}119```120121### End user documentation122123See [application_development.md](application_development.md)124125### Docker images for running deliverables for acceptance126127**Substrate Node (in dev mode), Unit tests for NFT Module**128129See above, the unit tests are run before the node starts within the same image.130131### Acceptance instructions132133**using Polkadot UI from https://substrate-ui.parity.io/**134135This document, except we are using Substrate v2, so we can use the newer version of the UI:136https://polkadot.js.org/apps/#137138## Milestone 2139140### NFT Tracking Module141142**Note:** If you have destroyed collection, create it again using `nft`.`createCollection` method.143144**Note 2:** The order of items in this section is different from the original spec to make the acceptance workflow more145natural.146147If you did not destroy collection while looking at Milestone 1 deliverables, use collection ID 1 in the further148examples, otherwise use collection ID = 2.149150#### CreateItem151152Before creating an NFT item, let's read ALICE balance for your collection, which indicates how many NFT tokens ALICE153owns in this collection. Read the chain state `nft`.`balance(<Collection ID>, ALICE)`, and it will be 0.154155Execute extrinsic `nft`.`createItem` from ALICE account. Set properties to `0x01`. Now if you read the chain state156`nft`.`balance(<Collection ID>, ALICE)`, it will be equal to 1. Also, you can read chain state157`nft`.`itemList(<Collection ID>, 1)`, and it will return data for the token 1:158159```160nft.itemList: NftItemType161{162  Collection: 1,163  Owner: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY,164  Data: 0x01165}166```167168#### GetOwner169170Reading the ownership is done by reading chainstate `nft`.`itemList(<Collection ID>, 1)`. One of the returned fields is171Owner:172173```174nft.itemList: NftItemType175{176  Collection: 1,177  Owner: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY,178  Data: 0x01179}180```181182#### Transfer183184Execute `nft`.`transfer` from ALICE address to transfer token 1 to BOB and check the ownership again:185186```187nft.itemList: NftItemType188{189  Collection: 1,190  Owner: 5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty,191  Data: 0x01192}193```194195Transfer the token 1 back to ALICE to enable further demo actions.196197#### BalanceOf198199Read the chain state `nft`.`balance` for ALICE address and see that she owns 1 token:200201```202nft.balance: u642031204```205206#### AddCollectionAdmin207208Execute `nft`.`AddCollectionAdmin` from ALICE account and let CHARLIE be an admin. Now you can see that CHARLIE can209transfer ALICE's token from ALICE's account to EVE and back. Also, you can read admin list from chain state and see that210it is not empty:211212```213nft.adminList: Vec<AccountId>214[215  5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y216]217```218219#### RemoveCollectionAdmin220221Execute `nft`.`RemoveCollectionAdmin` from ALICE account to remove CHARLIE from admins. Now you can see that CHARLIE222cannot transfer ALICE's tokens anymore. If you read the chan state `nft`.`adminList`, the response will be empty:223224```225nft.adminList: Vec<AccountId>226[]227```228229#### BurnItem230231Execute `nft`.`burnItem` from ALICE account to burn token 1, and then read the chain state232`nft`.`itemList(<Collection ID>, 1)`. This time the chain state returns default values in fields because token does not233exist anymore. You can also check ALICE balance in chain state, now it is equal 0 again.234235```236nft.itemList: NftItemType237{238  Collection: 0,239  Owner: 5C4hrfjw9DjXZTzV3MwzrrAr9P1MJhSrvWGWqi1eSuyUpnhM,240  Data: 0x241}242```243244### Economic Model Specification245246[Economic Model Specification](economic_model.md)247248### Contracts Module Specification249250https://docs.google.com/document/d/1gDtYjPR9C1VZChxEA-xAdQWQyEvMg245XrZR_MpE3cg/edit?usp=sharing251252### Bonus goal253254**Basic demo - Cryptopunks representation on the Substrate Chain.**255256See this repo, it has running and playing instructions: https://github.com/usetech-llc/substrapunks